1

我在 findHomography 函数中使用了 CV_RANSAC 选项,但现在我想使用 estimateRigidTransform。因此我不能再使用 CV_RANSAC。

我想消除我的 SIFT 特征匹配数据的异常值并应用estimateRigidTransform。我怎样才能做到这一点?

4

1 回答 1

2

这是一个对我有用的解决方案:

  • 使用 SURF 描述符和提取器获取特征点
  • 使用 FLANN-matcher 获得好的匹配
  • 交叉检查所有匹配项。我是这样做的:

    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);
      }
    }
    
    • 使用了estimateRigidTransform 函数。

我希望这在某种程度上有所帮助。如果您需要更多信息,请告诉我:)

于 2014-08-13T07:52:32.960 回答