Hi,
I’m trying to test different ways to get the keypoints to use in SparsePyrLKOpticalFlow.
My code at the moment more or less is the following:
std::vectorcv::KeyPo int> keypoints;
cv::Ptr<cv::cuda::FastFeatureDetector> p = cv::cuda::FastFeatureDetector::create(); p->detect(prev_grey, keypoints); std::cout << "keypointsSize: " << keypoints.size() << std::endl; cv::cuda::GpuMat test2(1, keypoints.size(), CV_32FC2, static_cast<void *>(keypoints.data())); std::cout << "created: " << test2.cols << std::endl; cv::Ptr<cv::cuda::SparsePyrLKOpticalFlow> d_pyrLK_sparse = cv::cuda::SparsePyrLKOpticalFlow::create(cv::Size(win_size, win_size), max_level); std::cout << "info: " << test2.type() << "; " << test2.cols << "; " << test2.rows << std::endl; d_pyrLK_sparse->calc(use_gray ? prev_grey : prev_frame_resize, use_gray ? cur_grey : cur_resize, test2, d_next_pts, d_status);
When I use this code on another Windows PC it works perfectly, but when I try to use it on my Jetson Xavier AGX I get the next error:
OpenCV(4.4.0) /home/nvidia/opencv_contrib 4.4.0/modules/cudev/include/opencv2/cudev/grid/detail/transform.hpp:267: error: (-217:Gpu API call) an illegal memory access was encountered in function ‘call’
Another detail is that if I use the following code:
cv::Ptrcv::cuda::CornersDetector detector = cv::cuda::createGoodFeaturesToTrackDetector(prev_grey.type(), max_corners, quality_level, min_dist);
detector->detect(prev_grey, d_prev_pts);
cv::Ptrcv::cuda::SparsePyrLKOpticalFlow d_pyrLK_sparse = cv::cuda::SparsePyrLKOpticalFlow::create(cv::Size(win_size, win_size), max_level);
d_pyrLK_sparse->calc(use_gray ? prev_grey : prev_frame_resize, use_gray ? cur_grey : cur_resize, d_prev_pts, d_next_pts, d_status);
The program works correctly. I don’t understand the error because in both cases I use a GpuMat.
Thanks in advance