Skip to content

[Feature Request] Add Python support for SFM – triangulatePoints function #3914

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
FrancescoSpena opened this issue Mar 27, 2025 · 4 comments

Comments

@FrancescoSpena
Copy link

Describe the feature and motivation

Description:

Currently, OpenCV provides the Structure From Motion (SFM) module only in C++, and there is no official Python binding for it. I have implemented a pure Python version of the cv::sfm::triangulatePoints function, which allows triangulating 3D points from 2D image correspondences and projection matrices. I would like to contribute this function to OpenCV, and I have a few questions regarding the best approach:

Should I create a new sfm module inside opencv_contrib to host this function and possibly other SFM-related utilities in the future? If a new sfm module is not the right approach, where would be the best place to integrate this function? (e.g., calib3d, multiview)? Is there any existing plan to add Python support for SFM in OpenCV?

Proposed Contribution:

  • A Python implementation of triangulatePoints, equivalent to the C++ version in OpenCV.
  • Unit tests to ensure correctness.
  • Documentation and example usage.
  • (If approved) A new sfm module in opencv_contrib to facilitate future additions.

I am open to feedback on the best way to integrate this contribution. Let me know if you need any additional details! 🚀

Additional context

OpenCV Version:
Platform: Ubuntu 20.04, Python 3.8.10

@4444Harsh
Copy link

Hi @FrancescoSpena,
I’m interested in contributing to this feature. I have experience in Python and OpenCV, and I’d love to help implement and test the Python version of triangulatePoints.
Before proceeding, I’d like to clarify whether we should integrate it into calib3d, multiview, or create a new sfm module in opencv_contrib. Do the maintainers have any preferences?
Looking forward to feedback!

@FrancescoSpena
Copy link
Author

Thank you for your interest in contributing! Actually, the code is already complete, and the necessary folders are set up, so I don’t need help with the implementation. I opened this issue just to clarify where it would be best to place my code—whether in calib3d, multiview, or in a new sfm module in opencv_contrib. It would be great to get some input from the maintainers on this.

Thanks for your time and support! 😊

@4444Harsh
Copy link

@FrancescoSpena
Got it, thanks for the update! I think adding an sfm module in opencv_contrib makes sense if there are plans for more SFM-related features in the future. Otherwise, multiview could be a good fit.

I'll follow the discussion and would be happy to help with testing or documentation if needed. Looking forward to the maintainers’ input!

@asmorkalov
Copy link
Contributor

  1. OpenCV generates Python bindings automatically from the modules header files. So the python function call uses the same C++ implementation, but converts data for python in both directions. triangulatePoints marked with CV_EXPORTS_W macro and should be wrapped to Python automatically.

  2. OpenCV packages distributed by OpenCV team includes opencv_contrib, but with limitations: some of modules have inappropriate license, some - have heavy dependencies. SFM is disabled by dependency, in particular.

    Unavailable:                 alphamat cannops cudaarithm cudabgsegm cudacodec cudafeatures2d cudafilters cudaimgproc cudalegacy cudaobjdetect cudaoptflow cudastereo cudawarping cudev fastcv freetype hdf java julia matlab ovis python2 sfm ts viz

To get it available you have to build OpenCV with contrib by yourself. As alternative, you can try OpenCV 5.x branch with 3d module: https://docs.opencv.org/5.x/da/d35/group____3d.html#gad3fc9a0c82b08df034234979960b778c

@asmorkalov asmorkalov transferred this issue from opencv/opencv Mar 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants