2012-11-16 12 views
10

Non riesco a trovare nessuna informazione su come utilizzare il rilevatore di punti chiave BRISK e l'estrattore in OpenCV su C/C++. Se qualcuno lo sa, per favore, scrivi il codice o fornisci un riferimento. Grazie!Come utilizzare BRISK in OpenCV?

P.S .: E come utilizzarlo in OpenCV 2.4.3?

+8

Ho pensato che fosse una domanda perfettamente ragionevole. Voi ragazzi chiudete questo come "non costruttivo", semplicemente non capita di avere questo problema. – Rob

risposta

20

Un altro modo per ottenere vivace in OpenCV 2.4.3

includere file di intestazione "opencv2/features2d/features2d.hpp" dove la classe vivace è implementata

// leggere alcune immagini in scala di grigi

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; 

// impostare parametri vivace

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

// dichiarare una variabile BRISKD del tipo cv :: BRISK

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); 

Dichiarare un tipo fuori matcher

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

un altro match che può essere utilizzato

//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); 

è anche possibile utilizzare: interfacce comuni di rivelatori Feature

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); 

il risultato con questo codice è simile a questo http://docs.opencv.org/_images/Feature_Description_BruteForce_Result.jpg

Problemi correlati