Cuda ORB GpuMat assertion failed
My Opncv python code running ok on CPU, now I would like use it with cuda acceleration. Being fairly new to Opencv and Cuda I would like to ask fro some help. I am using a Jetson Nano just like MicTie in this post. Trying to run the same code but getting an error when trying to detect the keypoints.
import cv2
MAX_FEATURES = 100
GOOD_MATCH_PERCENT = 0.15
# load images into numpy
npMat1 = cv2.imread("archive/apple.jpg")
npMat2 =cv2.imread("archive/apple.jpg")
# upload into Cuda
cuMat1 = cv2.cuda_GpuMat()
cuMat2 = cv2.cuda_GpuMat()
cuMat1.upload(npMat1)
cuMat2.upload(npMat2)
# convert to Gray
cuMat1g = cv2.cuda.cvtColor(cuMat1, cv2.COLOR_RGB2GRAY)
cuMat2g = cv2.cuda.cvtColor(cuMat2, cv2.COLOR_RGB2GRAY)
# ORB
corb = cv2.cuda_ORB.create(MAX_FEATURES)
_kps1, _descs1 = corb.detectAndComputeAsync(cuMat1g, None)
_kps2, _descs2 = corb.detectAndComputeAsync(cuMat2g, None)
The error I get is:
_kps1, _descs1 = corb.detectAndComputeAsync(cuMat1g, None)
cv2.error: OpenCV(4.2.0) /tmp/build_opencv/opencv/modules/core/src/cuda_gpu_mat.cpp:155: error:
(-215:Assertion failed)
0 <= roi.x && 0 <= roi.width && roi.x + roi.width <= m.cols && 0 <= roi.y && 0 <= roi.height && roi.y + roi.height <= m.rows in function 'GpuMat'
I have not much of an idea what goes wrong, any idea what I do wrong in the code above?
Thanks
Which version of OpenCV are you using? I would check that the python test code works on your system?
Remove
self.
is not defined.The code above is taken directly from the python tests which you can run with
Alternatively you can use the code above directly, the sample images are located in https://github.com/opencv/opencv/tree... you can therefore replace
self.get_sample("samples/data/right01.jpg")
withcv.imread("<PATH_TO_OPENCV>/samples/data/right01.jpg")
.Thanks for the good questions and guidance. Both the test code and one I tried seems to run OK when used with the sample images (right01.jpg, right02.jpg), so I checked what the difference is between these and the ones I used. It is the size of the image. I tried to use 200x200 pix image. So I reduced the "nlevels" parameter from default value 8 to 7 and it then seems to run OK.
Now my question is: Why would the standard ORB detector work with the default values and cuda_ORB not?
While Researching on this issue I came across this bug report. It seems as if this problem was present for a while. Any recommendation on how to correct my code to overcome this problem?