2013-04-14 3 views

답변

23

OpenCV는 두 이미지와 관련된 호모 그래피 매트릭스를 찾기 위해 선택적으로 RANSAC을 사용할 수있는 cv::findHomography 기능을 가지고 있습니다. 이 함수는 예제 here에서 볼 수 있습니다.

은 특히 관심있는 코드의 섹션은 다음과 같습니다

FlannBasedMatcher matcher; 
std::vector<DMatch> matches; 
matcher.match(descriptors_object, descriptors_scene, matches); 

for(int i = 0; i < good_matches.size(); i++) 
{ 
    //-- Get the keypoints from the good matches 
    obj.push_back(keypoints_object[ good_matches[i].queryIdx ].pt); 
    scene.push_back(keypoints_scene[ good_matches[i].trainIdx ].pt); 
} 

Mat H = findHomography(obj, scene, CV_RANSAC); 

그런 다음 호모 그래피 행렬에 따라 이미지를 워프 기능 cv::perspectiveTransform을 사용할 수 있습니다. CV_RANSAC 이외의 cv::findHomography에 대한

다른 옵션은 모든 지점을 사용 0하고 최소 중간 방법을 사용 CV_LMEDS이다. 자세한 내용은 OpenCV 카메라 보정 설명서 here에서 확인할 수 있습니다.

관련 문제