求基于sift特征提取的图像匹配代码,最好是利用C++和opencv编写

首先利用sift提取特征相量,然后对特征相量进行匹配,得到匹配的点,最后对匹配的区域能够定位。

哈哈,我有一个基于opencv实现的sift,我把代码贴出来,你自己看看吧~~~

void sift_detector_and_descriptors(IplImage* i_left,IplImage* i_right)
{
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);
}

这就是核心代码了,至于opencv所要用到的库,你自己弄一下吧,每个人的opencv版本不一样,这个都市不同的,希望能够帮到你~
温馨提示:答案为网友推荐,仅供参考
第1个回答  2013-04-24
网上不是很多吗?改改就实现了,不难吧
相似回答