mirror of
https://github.com/opencv/opencv.git
synced 2026-12-02 13:16:32 -06:00
7ab720c3d12d20cbb0dfca95936ea282b6119d63
5.x port of #31296 (merged to 4.x), requested there. It is a clean cherry-pick of the same change. A Python str containing a lone surrogate, such as 'a\udcff', crashes the interpreter when it is passed to bindings that take a string, for example cv.putText, cv.imread or cv.imwrite. Python produces such strings for non-UTF-8 filenames on POSIX. getUnicodeString() in modules/python/src2/pycompat.hpp passed the NULL that PyUnicode_AsUTF8String() returns on failure to PyBytes_Check(). This PR adds the NULL check, so the pending UnicodeEncodeError is reported instead. Difference from 4.x: cv.getTextSize raises cv.error here, because 5.x has another overload; 4.x raises UnicodeEncodeError.
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: all new work goes to
5.x, while4.xaccepts only bug fixes and other minor fixes; - 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%