I am trying to implement ORB with CUDA in OpenCV. I created an ORB object and am attempting to run orb.detectAndComputeAsync() on a GpuMat. However, I am encountering the following error:
cv2.error: OpenCV(4.10.0-dev) ... 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 'cv::cuda::GpuMat::GpuMat'
I am trying to upload a grayscale image to the GPU and use CUDA's ORB for keypoint detection and descriptor computation. Below is the Python code that initializes ORB and attempts to run the detectAndComputeAsync() function:
# Initialize ORB for CUDA
orb = cv2.cuda.ORB.create(
nfeatures=1500,
scaleFactor=1.2,
nlevels=8,
edgeThreshold=31,
firstLevel=0,
WTA_K=4,
scoreType=cv2.ORB_HARRIS_SCORE
)
print(f"GPU Image Channels: {gpu_image.channels()}, Type: {gpu_image.type()}")
# Detect and compute descriptors
keypoints, gpu_descriptors = orb.detectAndComputeAsync(gpu_image, None)
The gpu_image I am passing has a size of (180, 290), a channel of 1, and a type of 0
Relevant C++ code referred by the error: The error message points to an assertion failure in the following C++ code within OpenCV's CUDA implementation:
cv::cuda::GpuMat::GpuMat(const GpuMat& m, Rect roi) :
flags(m.flags), rows(roi.height), cols(roi.width),
step(m.step), data(m.data + roi.y * step), refcount(m.refcount),
datastart(m.datastart), dataend(m.dataend),
allocator(m.allocator)
{
data += roi.x * elemSize();
CV_Assert(0 <= roi.x && 0 <= roi.width &&
roi.x + roi.width <= m.cols &&
0 <= roi.y && 0 <= roi.height &&
roi.y + roi.height <= m.rows);
if (refcount)
CV_XADD(refcount, 1);
if (rows <= 0 || cols <= 0)
rows = cols = 0;
updateContinuityFlag();
}
Additional Details: Environment: OpenCV 4.10.0-dev with CUDA support. GPU Image Size: (180, 290) (Height x Width). Image Type: Single-channel (grayscale) with type 0
What I've tried: I modified the code to ensure that the ROI is within the bounds of the GPU image, but I still get the error.
Any guidance on what could be causing this issue or how to fix it would be greatly appreciated.
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745628081a4636931.html
评论列表(0条)