关于图像匹配的问题,找到特征点后,怎么对齐?
opencv吧
全部回复
仅看楼主
level 4
饮梦者014 楼主
关于图像匹配的问题,找到特征点匹配点后后,怎么对齐?
程序如下:
#include<iostream>
#include <opencv2/opencv.hpp>
#include<string.h>
#include <stdio.h>
#include <opencv2/nonfree/features2d.hpp>
using namespace cv;
using namespace std;
int main(int argc, char* argv[])
{
/*Mat img1=imread("Image01.jpg");*/
Mat img1=imread("Image01_副本.jpg");
/*Mat img2=imread("Image02.jpg");*/
Mat img2=imread("Image02_副本.jpg");
//cvtColor(img1,img1,CV_RGB2GRAY);
//cvtColor(img2,img2,CV_RGB2GRAY);
//-- Step 1: Detect the keypoints using SURF Detector
int minHessian=400;
SurfFeatureDetector detector( minHessian );
std::vector<KeyPoint> keypoints_1, keypoints_2;//
detector.detect( img1, keypoints_1 );
detector.detect( img2, keypoints_2 );
//-- Step 2: Calculate descriptors (feature vectors)
SurfDescriptorExtractor extractor;
Mat descriptors_1, descriptors_2;//两个矩阵
extractor.compute( img1, keypoints_1, descriptors_1 );
extractor.compute( img2, keypoints_2, descriptors_2 );
//-- Step 3: Matching descriptor vectors using FLANN matcher
FlannBasedMatcher matcher;
// BruteForceMatcher<L2<float>> matcher;
std::vector< DMatch > matches;//
matcher.match( descriptors_1, descriptors_2, matches );/
Mat imgMatches;
drawMatches(img1, keypoints_1, img2, keypoints_2, matches, imgMatches);
namedWindow("Matches");
imshow("Matches", imgMatches);///
double max_dist = 0;
double min_dist = 100;
//-- Quick calculation of max and min distances between keypoints
for( int i = 0; i < descriptors_1.rows; i++ )//rows是行
{
double dist = matches[i].distance;
if( dist < min_dist ) min_dist = dist;
if( dist > max_dist ) max_dist = dist;
}
printf("-- Max dist : %f \n", max_dist );
printf("-- Min dist : %f \n", min_dist );
//-- Draw only "good" matches (i.e. whose distance is less than 2*min_dist )
//-- PS.- radiusMatch can also be used here.
std::vector< DMatch > good_matches;
for( int i = 0; i < descriptors_1.rows; i++ )
{
if( matches[i].distance < 2*min_dist )
{
good_matches.push_back( matches[i]);
}
}
//-- Draw only "good" matches仅仅绘制
Mat img_matches;
drawMatches( img1, keypoints_1, img2, keypoints_2,
good_matches, img_matches, Scalar::all(-1), Scalar::all(-1),
vector<char>(), DrawMatchesFlags::NOT_DRAW_SINGLE_POINTS );
imshow( "Good Matches & Object detection", img_matches );
waitKey();
return 0;
}
求助!!!是个图像处理的新手,可以看懂程序,但是就是想不到自己要怎么写下去才行。
2016年04月27日 08点04分 1
level 4
饮梦者014 楼主
问题还是没有解决 再上来问一下 假如是需要拼接图像的话 找到特征点 透视变化过后 要怎么拼接 或者对齐图像?!!!
2016年05月16日 14点05分 3
level 4
饮梦者014 楼主
求大神!!!
2016年05月17日 00点05分 4
level 4
饮梦者014 楼主
暖贴!!求助!!!
2016年05月17日 08点05分 5
level 4
饮梦者014 楼主
求助啊 或者求个大神做朋友 能指教一二就好啊
2016年05月17日 15点05分 6
level 12
用ransac计算基本矩阵,获得变换矩阵,固定一张图片,对另一张图像进行仿射变换,然后新建一个大图往里写数据
2016年05月18日 01点05分 7
哦哦!!! 好的!!! 非常感谢 我先试试 因为是新手 我们老师和我说的是我这个实验不需要仿射变换 只需要找到匹配部分 对齐平移就可以
2016年05月18日 01点05分
方便留个扣扣联系一下吗?有些问题如果你方便不忙的时候能指点一下吗? 要是你觉得麻烦就算了 还是十分感谢终于有人回我了
2016年05月18日 01点05分
@饮梦者014 89461003
2016年05月18日 01点05分
level 1
你好,我也是做这个的新手,能加个好友吗,希望能有所交流,qq1358423791
2016年08月31日 08点08分 8
level 1
楼主,想请教您。我也是做到你这里不会了。跪求,技术交流。
2016年09月01日 01点09分 9
1