Hello,
I faced the problem that running following code (taken from 'samples/gpu/surf_keypoint_matcher.cpp' ) produces weird results for some images: SURF on CUDA finds "a column of random points" always near the right edge of an image. Moreover processing such images (for example, seaman.jpg, uav.JPG ) with SURF on CUDA more than once produces different amount of keypoints, while SURF on CPU always finds the same number of keypoints without any "weird" points.
I've noticed that maximum number of keypoints found by SURF on CUDA is restricted to max value of 16-bit unsigned integer (65535), maybe there are more restrictions?
Any ideas why this is happening? Has someone else already reported the issue?... I'm using OpenCV 3.1.0.
#include <iostream>
#include "opencv2/core/core.hpp"
#include "opencv2/features2d/features2d.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/cudafeatures2d.hpp"
#include "opencv2/xfeatures2d/cuda.hpp"
#include "opencv2/opencv_modules.hpp"
using namespace std;
using namespace cv;
using namespace cv::cuda;
int main(int argc, char *argv[])
{
cuda::setDevice(0);
GpuMat img1, img2;
img1.upload(imread("seaman.jpg", IMREAD_GRAYSCALE));
img2.upload(imread("seaman.jpg", IMREAD_GRAYSCALE));
SURF_CUDA surf;
GpuMat keypoints1GPU, keypoints2GPU;
GpuMat descriptors1GPU, descriptors2GPU;
surf(img1, GpuMat(), keypoints1GPU, descriptors1GPU);
surf(img2, GpuMat(), keypoints2GPU, descriptors2GPU);
cout << "FOUND " << keypoints1GPU.cols << " keypoints on first image" << endl;
cout << "FOUND " << keypoints2GPU.cols << " keypoints on second image" << endl;
// matching descriptors
Ptr<cv::cuda::DescriptorMatcher> matcher = cv::cuda::DescriptorMatcher::createBFMatcher(surf.defaultNorm());
vector<DMatch> matches;
matcher->match(descriptors1GPU, descriptors2GPU, matches);
// downloading results
vector<KeyPoint> keypoints1, keypoints2;
vector<float> descriptors1, descriptors2;
surf.downloadKeypoints(keypoints1GPU, keypoints1);
surf.downloadKeypoints(keypoints2GPU, keypoints2);
surf.downloadDescriptors(descriptors1GPU, descriptors1);
surf.downloadDescriptors(descriptors2GPU, descriptors2);
// drawing the results
Mat img_matches;
drawMatches(Mat(img1), keypoints1, Mat(img2), keypoints2, matches, img_matches);
imwrite("seaman_result.jpg", img_matches);
namedWindow("matches", 0);
imshow("matches", img_matches);
waitKey(0);
cuda::resetDevice();
return 0;
}
Running SURF on CUDA for seaman.jpg: 1) 693 keypoints and 2) 620 keypoints for the same image
Running SURF on CPU for seaman.jpg: equal amount of points for identical images (513 keypoints)