OpenCV图像匹配算法之orb
2015-01-09 10:25
507 查看
utils.cpp与utils.h
//orb.cpp #include "stdafx.h" #include <cv.hpp> #include <highgui.h> #include "utils.h" #include <iostream> using namespace std; void orb(char* path1, char* path2, INFO& info, bool show) { double t1,t2; t1=cvGetTickCount(); initModule_nonfree(); Mat img1, img2; img1=imread(path1,0); img2=imread(path2,0); if(img1.data==NULL) { cout<<"The image can not been loaded: "<<path1<<endl; system("pause"); exit(-1); } if(img2.data==NULL) { cout<<"The image can not been loaded: "<<path2<<endl; system("pause"); exit(-1); } Ptr<OrbFeatureDetector> orb_detector; Ptr<DescriptorExtractor> orb_descriptor; vector<KeyPoint> kpts1_orb, kpts2_orb; Mat desc1_orb, desc2_orb; Ptr<cv::DescriptorMatcher> matcher_l1 = DescriptorMatcher::create("BruteForce-Hamming"); //二进制汉明距离匹配 vector<Point2f> matches_orb, inliers_orb; vector<vector<DMatch> > dmatches_orb; orb_detector = new cv::OrbFeatureDetector(ORB_MAX_KPTS,ORB_SCALE_FACTOR,ORB_PYRAMID_LEVELS, ORB_EDGE_THRESHOLD,ORB_FIRST_PYRAMID_LEVEL,ORB_WTA_K,ORB_PATCH_SIZE); orb_descriptor = new cv::OrbDescriptorExtractor(); orb_detector->detect(img1,kpts1_orb); orb_detector->detect(img2,kpts2_orb); info.n1 = kpts1_orb.size(); info.n2 = kpts2_orb.size(); orb_descriptor->compute(img1,kpts1_orb,desc1_orb); orb_descriptor->compute(img2,kpts2_orb,desc2_orb); matcher_l1->knnMatch(desc1_orb,desc2_orb,dmatches_orb,2); matches2points_nndr(kpts1_orb,kpts2_orb,dmatches_orb,matches_orb,DRATIO); info.m=matches_orb.size()/2; compute_inliers_ransac(matches_orb,inliers_orb,MIN_H_ERROR,false); info.rm=inliers_orb.size()/2; t2=cvGetTickCount(); info.t=(t2-t1)/1000000.0/cvGetTickFrequency(); Mat img1_rgb_orb = imread(path1,1); Mat img2_rgb_orb = imread(path2,1); Mat img_com_orb = Mat(Size(img1.cols*2,img1.rows),CV_8UC3); if(show == true) { draw_inliers(img1_rgb_orb,img2_rgb_orb,img_com_orb,inliers_orb,2); imshow("orb",img_com_orb); waitKey(0); } return; }使用
INFO orb_info; orb(path1,path2,orb_info,false); showInfo(orb_info);
相关文章推荐
- OpenCV图像匹配算法之brisk
- opencv图像匹配算法
- OpenCV图像匹配算法之freak
- opencv图像特征检测及匹配(harris,sift,surf,fast,breif,orb,BFmatch,FlannBasedMatcher)
- OpenCV--LSH算法图像匹配
- opencv学习-模板匹配算法(单图像模板匹配和基于模板匹配的目标跟踪)
- 图像匹配算法之ORB
- Opencv下利用SIFT、SURF、ORB三种特征点实现图像匹配
- OpenCV图像匹配算法之sift
- 图像匹配之感知哈希(pHash)算法的OpenCV实现
- 基于ORB特征提取算法图像匹配 python实现
- 【OpenCV】SURF算法之视频图像实时特征点匹配
- Opencv下利用SIFT、SURF、ORB三种特征点实现图像匹配
- OpenCV图像匹配算法之brisk
- OpenCV4Android学习之图像特征匹配算法
- opencv3中ORB算法描述与匹配
- OpenCV图像匹配算法之surf
- Android Jni OpenCV-基于ORB算法特征点匹配
- OpenCv学习之利用ORB算法完成图像拼接
- 【图像算法OpenCV】几何不变矩--Hu矩