sfm: Fix declarations to make Python bindings work#4111
Open
emilepaul wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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).
Patch to opencv_extra has the same branch name.