mirror of
https://github.com/opencv/opencv.git
synced 2026-11-09 18:04:29 -06:00
71babee383e846ce4a037a7aa4a92c72551c4866
docs(imgproc): correct the documented Sobel kernel size range - #30661 ## Problem `cv::Sobel` and `cv::getDerivKernels` document the kernel size as > `@param ksize size of the extended Sobel kernel; it must be 1, 3, 5, or 7.` > `@param ksize Aperture size. It can be FILTER_SCHARR, 1, 3, 5, or 7.` but `getDerivKernels` (modules/imgproc/src/deriv.cpp) actually enforces a different constraint: ```cpp if( _ksize % 2 == 0 || _ksize > 31 ) CV_Error( cv::Error::StsOutOfRange, "The kernel size must be odd and not larger than 31" ); ``` so every odd size up to 31 is accepted, and `FILTER_SCHARR` (-1) selects the 3x3 Scharr kernels. Reproduced with opencv-python-headless 5.0.0: ``` getDerivKernels(1, 0, 9) -> OK, 9-tap kernel getDerivKernels(1, 0, 15) -> OK, 15-tap kernel getDerivKernels(1, 0, 31) -> OK, 31-tap kernel getDerivKernels(1, 0, 33) -> error: "The kernel size must be odd and not larger than 31" getDerivKernels(1, 0, -1) -> OK (Scharr 3x3) cv2.Sobel(img, cv2.CV_32F, 1, 0, ksize=9/15) -> OK cv2.Sobel(img, cv2.CV_32F, 1, 0, ksize=101) -> error (out of range) ``` ## Change Documentation-only: the two `@param ksize` entries now state the constraint the implementation enforces (odd, not larger than 31) while keeping 1, 3, 5, 7 as the typical choices. No code change. Signed-off-by: NUAAwqy <162230229@nuaa.edu.cn>
OpenCV: Open Source Computer Vision Library
Resources
- Homepage: https://opencv.org
- Courses: https://opencv.org/courses
- Docs: https://docs.opencv.org/5.x/
- Q&A forum: https://forum.opencv.org
- previous forum (read only): http://answers.opencv.org
- Issue tracking: https://github.com/opencv/opencv/issues
- Additional OpenCV functionality: https://github.com/opencv/opencv_contrib
- Donate to OpenCV: https://opencv.org/support/
Contributing
Please read the contribution guidelines before starting work on a pull request.
Summary of the guidelines:
- One pull request per issue;
- Choose the right base branch;
- Include tests and documentation;
- Clean up "oops" commits before submitting;
- Follow the coding style guide.
Additional Resources
- Submit your OpenCV-based project for inclusion in Community Friday on opencv.org
- Subscribe to the OpenCV YouTube Channel featuring OpenCV Live, an hour-long streaming show
- Follow OpenCV on LinkedIn for daily posts showing the state-of-the-art in computer vision & AI
- Apply to be an OpenCV Volunteer to help organize events and online campaigns as well as amplify them
- Follow OpenCV on Mastodon in the Fediverse
- Follow OpenCV on X
- OpenCV.ai: Computer Vision and AI development services from the OpenCV team.
Description
Languages
C++
87.7%
C
3.1%
Python
2.9%
CMake
2%
Java
1.5%
Other
2.6%