求opencv实现sift算法的程序 5
2个回答
展开全部
哈哈,我有一个基于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);
}
这就是核心代码了。 还有什么不懂,请追问
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的源码就好了。
使用的话方法不一,传送门:
http://www.cnblogs.com/tornadomeet/archive/2012/03/08/2384843.html
使用的话方法不一,传送门:
http://www.cnblogs.com/tornadomeet/archive/2012/03/08/2384843.html
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询