Find homography with SURF_OCL

asked 2015-05-14 02:14:55 -0600

bjorn89 gravatar image

Hi all, I'm trying to use Surf with ocl for speed up the feature finding,and then to use them for calculate homography. I'm using this code for finding the feature:

SURF_OCL surf;
BFMATCHER_OCL matcher;
vector<KeyPoint> keypoints1, keypoints2;
vector<DMatch> matches;
oclMat descriptors1GPU, descriptors2GPU;

surf(img1, oclMat(), keypoints1, descriptors1GPU);
surf(img2, oclMat(), keypoints2, descriptors2GPU);
matcher.match(descriptors1GPU, descriptors2GPU, matches);

The matches array il filled with a lot of elements (like 3000 or 4000) but when I do this code

double max_dist = 0; double min_dist = 100;

//-- Quick calculation of max and min distances between keypoints
for( int i = 0; i < descriptors_object.rows; i++ )
{ double dist = matches[i].distance;
  if( dist < min_dist ) min_dist = dist;
  if( dist > max_dist ) max_dist = dist;
}

max and min dist remains the same so when I'm taking good matches with this

vector< DMatch > good_matches;

for( int i = 0; i < descriptors_object.rows; i++ )
{ if( matches[i].distance < 3*min_dist )
   { good_matches.push_back( matches[i]); }
}

I've an empty array.

What can I do?

edit retag flag offensive close merge delete