2012-11-16 45 views
10

我在C/C++上找不到關於如何在OpenCV中使用BRISK關鍵點檢測器和提取器的任何信息。如果有人知道,請寫下代碼或提供參考。謝謝!如何在OpenCV中使用BRISK?

P.S.:以及如何在OpenCV 2.4.3中使用它?

+8

我認爲這是一個完全合理的問題。你們把這個視爲「不具有建設性」就不會遇到這個問題。 – Rob

回答

20

的另一種方式在OpenCV中得到輕快2.4.3

包括頭文件 「opencv2/features2d/features2d.hpp」,其中輕快類被實現

//灰度

讀一些圖像
const char * PimA="box.png"; // object 
const char * PimB="box_in_scene.png"; // image 

cv::Mat GrayA =cv::imread(PimA); 
cv::Mat GrayB =cv::imread(PimB); 

std::vector<cv::KeyPoint> keypointsA, keypointsB; 
cv::Mat descriptorsA, descriptorsB; 

//設置輕快參數

int Threshl=60; 
int Octaves=4; (pyramid layer) from which the keypoint has been extracted 
float PatternScales=1.0f; 

//聲明一個變量該類型品種::活潑而BRISKD

cv::BRISK BRISKD(Threshl,Octaves,PatternScales);//initialize algoritm 
BRISKD.create("Feature2D.BRISK"); 

BRISKD.detect(GrayA, keypointsA); 
BRISKD.compute(GrayA, keypointsA,descriptorsA); 

BRISKD.detect(GrayB, keypointsB); 
BRISKD.compute(GrayB, keypointsB,descriptorsB); 

聲明一個類型的離匹配

cv::BruteForceMatcher<cv::Hamming> matcher; 

另一場比賽中,可以使用

//cv::FlannBasedMatcher matcher(new cv::flann::LshIndexParams(20,10,2)); 


std::vector<cv::DMatch> matches; 
matcher.match(descriptorsA, descriptorsB, matches); 

    cv::Mat all_matches; 
    cv::drawMatches(GrayA, keypointsA, GrayB, keypointsB, 
         matches, all_matches, cv::Scalar::all(-1), cv::Scalar::all(-1), 
         vector<char>(),cv::DrawMatchesFlags::NOT_DRAW_SINGLE_POINTS); 
    cv::imshow("BRISK All Matches", all_matches); 
    cv::waitKey(0); 

    IplImage* outrecog = new IplImage(all_matches); 
    cvSaveImage("BRISK All Matches.jpeg", outrecog); 

你也可以使用:特徵檢測器的常用接口

cv::Ptr<cv::FeatureDetector> detector = cv::Algorithm::create<cv::FeatureDetector>("Feature2D.BRISK"); 

detector->detect(GrayA, keypointsA); 
detector->detect(GrayB, keypointsB); 

cv::Ptr<cv::DescriptorExtractor> descriptorExtractor =cv::Algorithm::create<cv::DescriptorExtractor>("Feature2D.BRISK"); 

descriptorExtractor->compute(GrayA, keypointsA, descriptorsA); 
descriptorExtractor->compute(GrayB, keypointsB, descriptorsB); 

此代碼的結果就像這樣 http://docs.opencv.org/_images/Feature_Description_BruteForce_Result.jpg