* Replaced most remaining sprintf with snprintf
* Deprecated encodeFormat and introduced new method that takes the buffer length
* Also increased buffer size at call sites to be a little bigger, in case int is 64 bit
Added explicit cast to unsigned before doing the left shift.
This was caught by UBSan which reported things like:
drawing.cpp:361:22: runtime error: left shift of negative value -26214
drawing.cpp:383:22: runtime error: left shift of negative value -78642
This makes LineSegmentDetector deterministic by using stable_sort for ordering points by norm. Without this change the region growing in LSD is non-determinstic and thus the returned lines are changing between invocations.
This is a replacement for https://github.com/opencv/opencv/pull/23370
In case of huge (and probably invalid) input, make sure we do not
rely only on the while loops for truncation.
### Pull Request Readiness Checklist
See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request
- [x] I agree to contribute to the project under Apache 2 License.
- [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV
- [x] The PR is proposed to the proper branch
Fix rect_nfa (lsd)
* Fix missing log_gamma in nfa()
Comparing the nfa function with the function in the binomial_nfa repository (https://github.com/rafael-grompone-von-gioi/binomial_nfa/blob/main/C99/log_binomial_nfa.c#L152), the first log_gamma call is missing.
* Fix rect_nfa pixel index
* Replace std::rotate
* Rename tmp to v_tmp
* Replace auto and std::min_element
* Change slope equality check to int
* Fix left limit check
Usage of imread(): magic number 0, unchecked result
* docs: rewrite 0/1 to IMREAD_GRAYSCALE/IMREAD_COLOR in imread()
* samples, apps: rewrite 0/1 to IMREAD_GRAYSCALE/IMREAD_COLOR in imread()
* tests: rewrite 0/1 to IMREAD_GRAYSCALE/IMREAD_COLOR in imread()
* doc/py_tutorials: check imread() result
Modify the SIMD loop in color_hsv.
* Modify the SIMD loops in color_hsv.
* Add FP supporting in bit logic.
* Add temporary compatibility code.
* Use max_nlanes instead of vlanes for array declaration.
* Use "CV_SIMD || CV_SIMD_SCALABLE".
* Revert the modify of the Universal Intrinsic API
* Fix warnings.
* Use v_select instead of bits manipulation.
In some situations the last value was missing from the discrete theta
values. Now, the last value is chosen such that it is close to the
user-provided maximum theta, while the distance to pi remains always
at least theta_step/2. This should avoid duplicate detections.
A better way would probably be to use max_theta as is and adjust the
resolution (theta_step) instead, such that the discretization would
always be uniform (in a circular sense) when full angle range is used.
[GSoC] New universal intrinsic backend for RVV
* Add new rvv backend (partially implemented).
* Modify the framework of Universal Intrinsic.
* Add CV_SIMD macro guards to current UI code.
* Use vlanes() instead of nlanes.
* Modify the UI test.
* Enable the new RVV (scalable) backend.
* Remove whitespace.
* Rename and some others modify.
* Update intrin.hpp but still not work on AVX/SSE
* Update conditional compilation macros.
* Use static variable for vlanes.
* Use max_nlanes for array defining.
It's not clear how ranges argument should be used in the overload of
calcHist that accepts std::vector. The main overload uses array of
arrays there, while std::vector overload uses a plain array. The code
interprets the vector as a flattened array and rebuilds array of arrays
from it. This is not obvious interpretation, so documentation has been
added to explain the expected usage.
Replaced sprintf with safer snprintf
* Straightforward replacement of sprintf with safer snprintf
* Trickier replacement of sprintf with safer snprintf
Some functions were changed to take another parameter: the size of the buffer, so that they can pass that size on to snprintf.