淺析ORB、SURF、SIFT特征點提取方法以及ICP匹配方法_第1頁
淺析ORB、SURF、SIFT特征點提取方法以及ICP匹配方法_第2頁
淺析ORB、SURF、SIFT特征點提取方法以及ICP匹配方法_第3頁
淺析ORB、SURF、SIFT特征點提取方法以及ICP匹配方法_第4頁
淺析ORB、SURF、SIFT特征點提取方法以及ICP匹配方法_第5頁
全文預覽已結束

下載本文檔

版權說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權,請進行舉報或認領

文檔簡介

第淺析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. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
  • 4. 未經(jīng)權益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責。
  • 6. 下載文件中如有侵權或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論