Hello, I would like to ask that how to pass arguments to cuda function reprojectImageTo3D?
The no cuda version works fine xyz = cv2.reprojectImageTo3D(disp.astype(np.float32), self.Q), but I want to improve the calculation speed with the cuda version function. However whatever the arguments I passed, there all has an error.
For example, I pass the GpuMat of disp and numpy array of Q, and the error is:
cv2.cuda.reprojectImageTo3D(disp=dispcu_resize, Q=self.Q)
Traceback (most recent call last):
File "<string>", line 1, in <module>
cv2.error: OpenCV(4.5.3-openvino) :-1: error: (-5:Bad argument) in function 'reprojectImageTo3D'
> Overload resolution failed:
> - disp is not a numpy array, neither a scalar
> - Expected Ptr<cv::cuda::GpuMat> for argument 'Q'
> - Expected Ptr<cv::UMat> for argument 'disp'
it should accept disp being a GpuMat, and not be that particular about one small 4x4 matrix of coefficients.
error says that the types have to be the other way around (almost)… which I find odd.
It could be that the python wrapper’s type resolution is in the way, checking/enforcing the wrong things. the function itself, as far as I can see, would agree with how you call it
please check the types of your arguments explicitly yourself, i.e. look at type(dispcu_resize) and type(self.Q)
Passing disp as a GpuMat does not work for me and causes the following error, that I’m not sure how to interpret:
error: OpenCV(4.5.4) /home/massimo/Downloads/opencv-4.5.4/modules/core/src/matrix_wrap.cpp:111: error: (-213:The function/feature is not implemented) You should explicitly call download method for cuda::GpuMat object in function 'getMat_'
Is it really not implemented in Python?
I’m using OpenCV 4.5.4 and the following minimal working example to understand how to use cv2.cuda.reprojectImageTo3D():
And also tried to pass all combinations of cu/np versions of disparity and q, but everything ends up in an error, either -5:Bad argument or -213:The function/feature is not implemented.
Any help would be much appreciated.
Thanks in advance!
Thanks @cudawarped!
Recompiling OpenCV with the suggested changes to modules/cudastereo/include/opencv2/cudastereo.hpp fixed cv2.cuda.reprojectImageTo3D() for me as well.
P.S. Have you considered submitting a pull request to opencv_contrib?
Funny I was going to ask you the same question. I’m a bit busy at the moment it was just by chance I had time yesterday to look into your post. Let me know if u don’t have time either and I’ll submit one in a couple of weeks.