Skip to content

sfm: Fix declarations to make Python bindings work#4111

Open
emilepaul wants to merge 1 commit into
opencv:4.xfrom
emilepaul:4.10.0-evb-fixsfmbindings
Open

sfm: Fix declarations to make Python bindings work#4111
emilepaul wants to merge 1 commit into
opencv:4.xfrom
emilepaul:4.10.0-evb-fixsfmbindings

Conversation

@emilepaul
Copy link
Copy Markdown

See issue #636

I ran into the same issue and would like to discuss/propose the remedy in this PR which allowed me to use the SFM module from Python.

Note 1: I had to add a CV_WRAP for SFMLibmvEuclideanReconstruction::create, just running the constructor produced a NULL self in pyopencv_generated_types_content.h when ->run() was called.

Note 2: Most of the other problems were solved by replacing OutputArray to OutputArrayOfArrays (distinction doesn't matter to the C++ type system but does matter to the Python bindings generator) to prevent GetMatRef(i) from throwing an assert on the OutputArray not being of a STD_VECTOR_MAT kind in all routines returning Ts and points3d.

I don't know if using a vector is the best choice for Ts and points3d output, I'd say a regular Mat with 3 columns would produce nicer Numpy arrays and something that serializes nicer to cv::FileStorage. But I didn't want to change any semantics.

Note 3: I also had to shorten SFMLibmvEuclideanReconstruction to SFMLibmvEuclideanRecons in order to avoid the Python bindings generator shortening/garbling it to SFMLibmvEuclideanReruction in pyopencv_generated_types_content.h (could also be that something overenthousiastically strips 'const' in the wrong way, I'm no expert on the bindings generators).

  • I agree to contribute to the project under Apache 2 License.
  • 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
  • The PR is proposed to the proper branch
  • There is a reference to the original bug report and related work
  • There is accuracy test, performance test and test data in opencv_extra repository, if applicable
    Patch to opencv_extra has the same branch name.
  • The feature is well documented and sample code can be built with the project CMake

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants