Ask Your Question

Revision history [back]

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

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