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
Allows structured_light pipeline to be run from Python #2452
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for contribution!
It would be nice if you could add simple test for Python API (no need to perform complex accuracy check).
See example: https://github.com/opencv/opencv_contrib/blob/4.2.0/modules/rgbd/misc/python/test/test_rgbd.py
or similar Python tests from main opencv repository.
Test data is stored in opencv_extra repository.
// alias for scripting | ||
CV_WRAP | ||
static Ptr<HistogramPhaseUnwrapping> create( int width, int height, float histThresh = static_cast<float>(3 * CV_PI * CV_PI), | ||
int nbrOfSmallBins = 10, int nbrOfLargeBins = 5); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please follow the existed practice and avoid unpacking of "Params" structure.
You can check this code as an example:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The existing practice is not clear as the structured_light itself is using 2 practices:
- Params unpacking in
GrayCodePattern::create
- smart pointer for
SinusoidalPattern::create
Some codes pass a smart pointer like this is done for SinusoidalPattern::create
but I followed the solution used by GrayCodePattern::create
Because changing the create API (instead of overloading it) will break current codes using structured_light.
The code you point out is not using Params struct to pass parameters.
If you just pass a const Params&
, the Python binding generator will not generate the needed code. Am I right ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Params" class should be marked for bindings wrapping too (use CV_EXPORTS_W_SIMPLE
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK. I managed to bind the HistogramPhaseUnwrapping::Params
; What I was missing is the typedef
in pyopencv_phase_unwrapping.hpp
as it is done in pyopencv_features2d.hpp
I added the Python test for structured_light replicating what is done in C++. However, this shown a "bug" in HistogramPhaseUnwrapping::unwrapPhaseMap
where the unwrappedPhaseMap
were uninitialized in places outside of the mask.
It is not clear if this were intentional or not.
SinusoidalPattern::unwrapPhaseMap now takes an InputArray instead of InputArrayOfArrays to correct a Python binding problem present a scriptable HistogramPhaseUnwrapping::create replicate C++ structured_light test in Python PhaseUnwrapping now init unwrappedPhase so pixel outside the mask area are set to 0 python binding for HistogramPhaseUnwrapping::Params to use HistogramPhaseUnwrapping::create
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well done! Thank you for contribution 👍
Hi the following codings make my python kernel die.
|
Which version of OpenCV are you using ? import cv2
print(cv2.__version__) You should have a recent 3.4 release (ideally 3.4.10) to get the correction Regards |
SinusoidalPattern::unwrapPhaseMap now takes an InputArray instead of InputArrayOfArrays to correct a Python binding problem
present a scriptable HistogramPhaseUnwrapping::create
This patch solves issue #1704 and allow to write a whole pipeline including reliability computation.
Pull Request Readiness Checklist
See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request
Patch to opencv_extra has the same branch name.