-
-
Notifications
You must be signed in to change notification settings - Fork 55.6k
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
Unexpect error when invoke cv2.sampsonDistance #25370
Comments
I did some poking around and found the lines that are producing this bug. opencv/modules/python/src2/cv2_convert.cpp Line 176 in e55cf44
This line makes arguments first and second multichannel
opencv/modules/python/src2/cv2_convert.cpp Line 215 in e55cf44
This line changes the type from float64( type id 6) to some other invalid type with type id 14 ( = 6 bitwise or 8 ) I hope this helps in fixing the bug. |
Possible fix if applicable CV_Assert((_pt1.type() & CV_MAT_DEPTH_MASK) == CV_64F && (_pt2.type() & CV_MAT_DEPTH_MASK) == CV_64F && _F.type() == CV_64F); |
I'd be more than happy to take over the issue if someone can do a basic code walkthrough for me, regarding what all places do I need to look into and such. |
Hey @beanduan22 . I started to read the documentation of the function |
that's what I can tell by reading the code. If the extent exceeds 2, it'll encode it as a multi-channel array. We could add another assert to check if it's a multi-channel array so that users can don't confuse this with an error. |
Any idea how we can do that? Do we need to do it manually? |
You could use the bit mask since ( Steps:
It should cover that case for multi-channel; however, this is a check that is too far in the code. If we can pass argument constraints info to the |
Yes, you need manual handling of this case, but you could just assert with a message. assert((_p1.type() < CV_MAT_DEPTH_MASK) && "Matrices or arrays of second order are only allowed") // This should indicate the user he's doing something wrong
This is an idea that could be refined further or a better approach might be possible than this. I'm just trying to give you a possible fix. template<>
bool pyopencv_to(PyObject* o, Mat& m, const ArgInfo& info) {
...
if (ndims != info.dims) { // Or (info.min_dims <= ndims && ndims < info.max_dims)
// handle error
}
} Something along this line. |
Thank you soo much @amitsingh19975 . Let me try this |
BTW, these "dims", "min_dims", or "max_dims" members do not exist inside the |
System Information
Python version: 3.8.18
OpenCV python version: 4.9.0
Operating System / Platform: Windows-10-10.0.19045-SP0
Detailed description
all of the input param I set were float64
Steps to reproduce
Issue submission checklist
The text was updated successfully, but these errors were encountered: