{
Mat mat_image_left=Mat(i_left,false);
Mat mat_image_right=Mat(i_right,false);
cv::SiftFeatureDetector *pDetector=new cv::SiftFeatureDetector;
pDetector->detect(mat_image_left,left_key_point);
pDetector->detect(mat_image_right,right_key_point);
Mat left_image_descriptors,right_image_descriptors;
cv::SiftDescriptorExtractor *descriptor_extractor=new cv::SiftDescriptorExtractor;
descriptor_extractor->compute(mat_image_left,left_key_point,left_image_descriptors);
descriptor_extractor->compute(mat_image_right,right_key_point,right_image_descriptors);
Mat result_l,result_r;
drawKeypoints(mat_image_left,left_key_point,result_l,Scalar::all(-1),0);
drawKeypoints(mat_image_right,right_key_point,result_r,Scalar::all(-1),0);
//imshow("result_of_left_detector_sift",result_l);
//imshow("result_of_right_detector_sift",result_r);
Mat result_of_sift_match;
BruteForceMatcher<L2<float>> matcher;
matcher.match(left_image_descriptors,right_image_descriptors,result_of_point_match);
drawMatches(mat_image_left,left_key_point,mat_image_right,right_key_point,result_of_sift_match,result_of_sift_match);
imshow("matches_of_sift",result_of_sift_match);
imwrite("matches_of_sift.jpg",result_of_sift_match);
}
void main()
{
IplImage *n_left_image=cvLoadImage("D:\\lena.jpg");
IplImage *n_right_image=cvLoadImage("D:\\lena_r.jpg");
sift_detector_and_descriptors(n_left_image,n_right_image);
cvWaitKey(0);
}
這個是我實現sift匹配的代碼,我就懂妳為什麽要用到 drawMatchesKnn() , 每個版本都是支持SIFT的,和版本沒有關系的。