1

I used CV_RANSAC option at findHomography function but now I want to use estimateRigidTransform. Thus I can no more use CV_RANSAC.

I want to eliminate outliers of my SIFT featured matched data and apply estimateRigidTransform. How can I do this?

2
  • Do you have a 2D or a 3D transform? The estimateRigidTransform-function assumes that your transformation is 2D. I have done a project where I used both findHomography and estimateRigidTransform with SURF, but this was by a fixed distance and in one plane. Can you explain what you want to compare? Commented Aug 12, 2014 at 14:44
  • I am working on panorama, thus 2D transform to stitch image to reference image. I used findHomography to stitch it projectively but it becomes spread out at the end. Thus I want to use similarity transform.
    – nelya9227
    Commented Aug 13, 2014 at 2:08

1 Answer 1

2

Here is a solution that worked for me:

  • Use SURF descriptor and extractor for getting feature points
  • Use FLANN-matcher to get good matches
  • Crosscheck all the matches. Here is how I did that:

    std::vector<Point2f> valid_coords_1, valid_coords_2;
    std::vector< DMatch > valid_matches;
    //-- Show detected matches
    
    
    int counter;
    float res;
    for( int i = 0; i < (int)good_matches.size(); i++ ){
      counter = 0;
      for(int j = 0; j < (int)good_matches.size(); j++){
        if(i!=j){
          res = cv::norm(keypoints_1[good_matches[i].queryIdx].pt - keypoints_1[good_matches[j].queryIdx].pt) - cv::norm(keypoints_2[good_matches[i].trainIdx].pt-keypoints_2[good_matches[j].trainIdx].pt);
          if(abs(res) < (img_1.rows * 0.004 + 3)){ //this value has to be adjusted
            counter++;
          }
          //printf("Match good point %d with %d: %f \n", i, j, res);
        }
      }
     /* printf( "-- Good Match [%d] Keypoint 1: %d (%f,%f)  -- Keypoint 2: %d (%f,%f) Distance: %f  \n", i, good_matches[i].queryIdx, 
        keypoints_1[good_matches[i].queryIdx].pt.x, keypoints_1[good_matches[i].queryIdx].pt.y, 
        good_matches[i].trainIdx, 
        keypoints_2[good_matches[i].trainIdx].pt.x, keypoints_2[good_matches[i].trainIdx].pt.y, 
        good_matches[i].distance); */
      //printf("Point nr %d: has %d valid matches \n", i, counter);
      if(counter > (good_matches.size() / 10)){
        valid_matches.push_back(good_matches[i]);
        valid_coords_1.push_back(keypoints_1[good_matches[i].queryIdx].pt);
        valid_coords_2.push_back(keypoints_2[good_matches[i].trainIdx].pt);
      }
    }
    
    • Used the estimateRigidTransform-function.

I hope this helped in some way. Please let me know if you need further information :)

1
  • THX! I will check this out! I was going to implement ransac by myself but this will help alot!
    – nelya9227
    Commented Aug 13, 2014 at 8:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.