我在findHomography函数中使用了CV_RANSAC选项,但现在我想使用estimateRigidTransform。因此我不能再使用CV_RANSAC了。
我想消除我的SIFT特色匹配数据的异常值并应用estimateRigidTransform。我怎么能这样做?
答案 0 :(得分:2)
这是一个对我有用的解决方案:
交叉检查所有比赛。我是这样做的:
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);
}
}
我希望这在某种程度上有所帮助。如果您需要更多信息,请与我们联系:)