opencv2.4.3特徵提取的實現表示方法

來源:互聯網
上載者:User

1.採用自訂的類實現形式

Another way to get brisk in OpenCV 2.4.3

include header file "opencv2/features2d/features2d.hpp" where brisk class is implemented

//read some images in gray scale

const char * PimA="box.png";   // objectconst char * PimB="box_in_scene.png"; // imagecv::Mat GrayA =cv::imread(PimA);cv::Mat GrayB =cv::imread(PimB);std::vector<cv::KeyPoint> keypointsA, keypointsB;cv::Mat descriptorsA, descriptorsB;

//set brisk parameters

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

//declare a variable BRISKD of the type cv::BRISK

cv::BRISK  BRISKD(Threshl,Octaves,PatternScales);//initialize algoritmBRISKD.create("Feature2D.BRISK");BRISKD.detect(GrayA, keypointsA);BRISKD.compute(GrayA, keypointsA,descriptorsA);BRISKD.detect(GrayB, keypointsB);BRISKD.compute(GrayB, keypointsB,descriptorsB);

Declare one type off matcher

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

another match that can be use

//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 );
2.採用通用介面
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);

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.