本文共 1490 字,大约阅读时间需要 4 分钟。
ORB特征原理:
/* *@function ORB_Detect.cpp *@brief 使用ORB特征对目标进行检测和匹配 *@author ltc *@date 14:45 Thursday,December 3rd,2015*/#include匹配结果:#include #include #include #include using namespace std;using namespace cv;vector ransac(vector queryKeyPoint,vector trainKeyPoint,vector matches);int main(int argc,char* argv[]){ Mat queryImage,trainImage; queryImage=imread("4.jpg",IMREAD_COLOR); trainImage=imread("3.jpg",IMREAD_COLOR); ORB orb; vector queryKeyPoint,trainKeyPoint; Mat queryDescriptor,trainDescriptor; orb(queryImage,Mat(),queryKeyPoint,queryDescriptor); orb(trainImage,Mat(),trainKeyPoint,trainDescriptor); drawKeypoints(queryImage,queryKeyPoint,queryImage); drawKeypoints(trainImage,trainKeyPoint,trainImage); cout< < matches; matcher.match(queryDescriptor,trainDescriptor,matches); vector ransac_matches; ransac_matches=ransac(queryKeyPoint,trainKeyPoint,matches); Mat image_match;// drawMatches(queryImage,queryKeyPoint,trainImage,trainKeyPoint,matches,image_match); drawMatches(queryImage,queryKeyPoint,trainImage,trainKeyPoint,ransac_matches,image_match); imshow("image_match",image_match); waitKey(0); return 0;}vector ransac(vector queryKeyPoint,vector trainKeyPoint,vector matches){ vector ransac_matches; vector queryPoint(matches.size()),trainPoint(matches.size()); for(int i=0;i inlierMask(matches.size()); Mat H=findHomography(queryPoint,trainPoint,RANSAC,3,inlierMask); for(size_t i=0;i