I am trying to implement a GPU version of some regular OpenCV code I have.
In particular, I perform Surf keypoint detection on only a user specified ROI of a larger Mat.
My non-GPU code looks like:
Mat roi(mask, cv::Rect(Images->CropLeft,Images->CropTop,twidth,theight));
roi = Scalar(255, 255, 255);
Images->SurfKeypoints.clear();
cvtColor(Images->LoadFrameClone,Images->GrayFrame,CV_BGR2GRAY);
SurfDetector->detect(Images->GrayFrame,Images->SurfKeypoints,mask);
Now, I want to do the same thing with a GPU version.
My GPU code (that does detect Surf kepoints looks like:
int theight = (Images->LoadFrameClone.rows-Images->CropBottom) - Images->CropTop;
int twidth = (Images->LoadFrameClone.cols-Images->CropRight)-Images->CropLeft;
dImages->LoadCanny();
Images->SurfKeypoints.clear();
cuda::SURF_CUDA surf = cuda::SURF_CUDA::SURF_CUDA(Images->Hessian);
surf(*dImages->d_gpuGrayFrame,cuda::GpuMat(),Images->SurfKeypoints);
This works fine but looks for keypoints in the entire image.
However, I only want to look for keypoints in an ROI.
I have tried:
surf(*dImages->d_gpuGrayFrame,cuda::GpuMat(*dImages->d_gpuGrayFrame,cv::Rect(Images->CropLeft,Images->CropTop,twidth,theight)),Images->SurfKeypoints);
This causes an immediate crash. In these code excerpts, a Top,Left position and a Bottom,Right position specify a region of interest. The LoadCanny operation performs the cvtColor operation to load a grayscale version of the image into d_gpuGrayFrame.
What do I need to do to specify that I only want keypoints from the ROI?
Thanks for any help.
↧