mirror of
https://github.com/opencv/opencv.git
synced 2026-01-18 17:21:42 +01:00
498853d9965b20993909c64586e485bc6d7c043a
Fix JS bindings for namespaced Ptr factory return types #28143 This PR fixes an issue in the JS bindings generator for factory functions returning cv::Ptr<T> where T belongs to a namespaced class (for example cv::ximgproc::EdgeDrawing). The generator previously produced unqualified C++ template arguments such as: .constructor(select_overload<Ptr<EdgeDrawing>()>(&cv::ximgproc::createEdgeDrawing)) This results in invalid C++ because EdgeDrawing is not found in the global namespace. Fixes https://github.com/opencv/opencv/issues/28130 In modules/js/generator/embindgen.py, inside both: gen_function_binding_with_wrapper gen_function_binding a check is added: When factory == True, And the return type begins with Ptr<...>, And the inner type is missing a namespace (::), Ptr<T> → Ptr<class_info.cname> This ensures the fully-qualified class name (e.g. cv::ximgproc::EdgeDrawing) is used in the generated bindings. .constructor(select_overload<Ptr<cv::ximgproc::EdgeDrawing>()>(&cv::ximgproc::createEdgeDrawing)) Configured OpenCV with: cmake .. -DBUILD_opencv_js=ON Ran: make -j gen_opencv_js_source JS generator completed successfully without errors. This change does not modify generated files directly — it modifies the generator logic so the correct namespace is applied automatically.
OpenCV: Open Source Computer Vision Library
Resources
- Homepage: https://opencv.org
- Courses: https://opencv.org/courses
- Docs: https://docs.opencv.org/4.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 Twitter
- OpenCV.ai: Computer Vision and AI development services from the OpenCV team.
Description
Languages
C++
87.5%
C
3.1%
Python
3%
CMake
2%
Java
1.5%
Other
2.7%