




下载本文档
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
第浅析ORB、SURF、SIFT特征点提取方法以及ICP匹配方法chrono::steady_clock::time_pointt1=chrono::steady_clock::now();
detector-detectAndCompute(temp,Mat(),keypoints_obj,descriptor_obj);
detector-detectAndCompute(image_check_changed,Mat(),keypoints_scene,descriptor_scene);
cout"detect"keypoints_obj.size()"and"keypoints_scene.size"keypoints"endl;
//matching
FlannBasedMatchermatcher;
vectorDMatchmatches;
matcher.match(descriptor_obj,descriptor_scene,matches);
chrono::steady_clock::time_pointt2=chrono::steady_clock::now();
chrono::durationdoubletime_used=chrono::duration_castchrono::durationdouble(t2-t1);
cout"extractandmatchcost="time_used.count()*1000"ms"endl;
//求最小最大距离
doubleminDist=1000;
doublemax_dist=0;
//row--行col--列
for(inti=0;idescriptor_obj.rows;i++)
doubledist=match[i].distance;
if(distmaxDist)
maxDist=dist;
if(distminDist)
minDist=dist;
//printf("maxdistance:%f\n",maxDist);
//printf("mindistance:%f\n",minDist);
//findgoodmatchedpoints
vectorDMatchgoodMatches;
for(imti=0;idescriptor_obj.rows;i++)
doubledist=matches[i].distance;
if(distmax(5*minDist,1.0))
goodMatches.push_back(matches[i]);
//rectangle(temp,Point(1,1),Point(177,157),Scalar(0,0,255),8,0);
cout"match"goodMatches.size()"keypoints"endl;
endTime=clock();
//cout"tooktime:"(double)(endTime-startTime)/CLOCKS_PER_SEC*1000"ms"endl;
MatmatchesImg;
drawMatches(temp,keypoints_obj,image_check_changed,keypoints_scene,goodMatches,
matchesImg,Scalar::all(-1),
Scalar::all(-1),vectorchar(),DrawMatchesFlags::NOT_DRAW_SINGLE_POINTS);
if(show_picture)
imshow("FlannMatchingResult01",matchesImg);
//imwrite("C:/Users/Administrator/Desktop/matchesImg04.jpg",matchesImg);
//求h
std::vectorPoint2fpoints1,points2;
//保存对应点
for(size_ti=0;igoodMatches.size();i++)
//queryIdx是对齐图像的描述子和特征点的下标。
points1.push_back(keypoints_obj[goodMatches[i].queryIdx].pt);
//queryIdx是是样本图像的描述子和特征点的下标。
points2.push_back(keypoints_scene[goodMatches[i].trainIdx].pt);
//Findhomography计算Homography,RANSAC随机抽样一致性算法
MatH=findHomography(points1,points2,RANSAC);
//imwrite("C:/Users/Administrator/Desktop/C-train/C-train/result/sift/Image4_SURF_MinHessian1000_minDist1000_a0.9b70.jpg",matchesImg);
vectorPoint2fobj_corners(4);
vectorPoint2fscene_corners(4);
obj_corners[0]=Point(0,0);
obj_corners[0]=Point(temp.count,0);
obj_corners[0]=Point(temp.cols,temp.rows);
obj_corners[0]=Point(0,temp.rows);
//透视变换(把斜的图片扶正)
perspectiveTransform(obj_corners,scene_corners,H);
//Matdst
cvtColor(image_check_changed,image_check_changed,COLOR_GRAY2BGR);
line(image_check_changed,scene_corners[0],scene_corners[1],Scalar(0,0,255),2,8,0);
line(image_check_changed,scene_corners[1],scene_corners[2],Scalar(0,0,255),2,8,0);
line(image_check_changed,scene_corners[2],scene_corners[3],Scalar(0,0,255),2,8,0);
line(image_check_changed,scene_corners[3],scene_corners[0],Scalar(0,0,255),2,8,0);
if(show_picture)
Matoutimg1;
Mattemp_color=imread(picture1,CV_LOAD_IMAGE_COLOR);
drawKeypoints(temp_color,keypoints_obj,outimg1,Scalar::all(-1),DrawMatchesFlags::DEFAULT);
imshow("AKAZEfeatures",outimg1);
if(show_picture)
waitKey(0);
voidextract_ORB(stringpicture1,stringpicture2)
Matimg_1=imread(picture1);
Matimg_2=imread(picture2);
resize(img_1,img_1,Size(),picture1_size_change,picture1_size_change);
resize(img_2,img_2,Size(),picture2_size_change,picture2_size_change);
if(!img_1.data||!img_2.data)
cout"errorreadingimages"endl;
return;
vectorPoint2frecognized;
vectorPoint2fscene;
recognized.resize(1000);
scene.resize(1000);
Matd_srcL,d_srcR;
Matimg_matches,des_L,des_R;
//ORB算法的目标必须是灰度图像
cvtColor(img_1,d_srcL,COLOR_BGR2GRAY);//CPU版的ORB算法源码中自带对输入图像灰度化,此步可省略
cvtColor(img_2,d_srcR,COLOR_BGR2GRAY);
PtrORBd_orb=ORB::create(1500);
Matd_descriptorsL,d_descriptorsR,d_descriptorsL_32F,d_descriptorsR_32F;
vectorKeyPointkeyPoints_1,keyPoints_2;
//设置关键点间的匹配方式为NORM_L2,更建议使用FLANNBASED=1,BRUTEFORCE=2,BRUTEFORCE_L1=3,BRUTEFORCE_HAMMING=4,BRUTEFORCE_HAMMINGLUT=5,BRUTEFORCE_SL2=6
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 租山合同协议书
- 治安协议书合同书
- 合同调解协议书模板
- 永电合同协议书
- 租地合同协议书文件
- 技术协议书合同
- 市场合同协议书
- 名片合同协议书
- 大豆合同协议书
- 机动车租赁合同协议书
- 广西2024年广西特种设备检验研究院招聘笔试上岸历年典型考题与考点剖析附带答案详解
- (高清版)JTGT 5440-2018 公路隧道加固技术规范
- 2024年青岛职业技术学院单招职业适应性测试题库各版本
- 智慧健康养老产业课件
- 中国应急管理的演化历程
- 2.6高压电力电容器运行与维护
- 碘缺乏病知识宣传课件
- 曙光医院网上查报告
- 港口危货作业单位主要安全管理人员试题及答案(536道)
- 教师职业道德与教育法律法规
- 汽车制造工艺与自动化检测过程自动化课件
评论
0/150
提交评论