OpenCV getting started, opencv

Source: Internet
Author: User

OpenCV getting started, opencv
OpenCV getting started-Key Point description child match Brute-force


The keypoint descriptors matching is performed after the feature vectors are extracted from the image to determine the matching degree between the specific image and the image in the training set. The BFMatcher Brute force matching class inherits from the abstract class DescriptorMatcher, "Brute-force descriptor matcher. for each descriptor in the first set, this matcher finds the closest descriptor in the second set by trying each one. this descriptor matcher supports masking permissible matches of descriptor sets ". The following shows the effect through a simple instance.

#include <opencv2/core/core.hpp>#include <opencv2/highgui/highgui.hpp>#include <opencv2/nonfree/features2d.hpp> //#include <iostream>using namespace cv;using namespace std;int main(int argc, const char *argv[]){    Mat car1 = imread("car1.jpeg", 0);// load as grayscale    Mat car2 = imread("car2.jpeg", 0);    SiftFeatureDetector detector;    vector<KeyPoint> keypoints1, keypoints2;    detector.detect(car1, keypoints1);    detector.detect(car2, keypoints2);    cout << "# keypoints of car1 :" << keypoints1.size() << endl;    cout << "# keypoints of car2 :" << keypoints2.size() << endl;       Mat descriptors1,descriptors2;    Ptr<DescriptorExtractor> extractor = DescriptorExtractor::create("SIFT");    extractor->compute(car1,keypoints1,descriptors1);    extractor->compute(car2,keypoints2,descriptors2);        BFMatcher bfmatcher(NORM_L2, true);    vector<DMatch> matches;    bfmatcher.match(descriptors1, descriptors2, matches);    cout << "# matches : " << matches.size() << endl;    // show it on an image    Mat output;    drawMatches(car1, keypoints1, car2, keypoints2, matches, output);    imshow("car matches result",output);    waitKey(0);    return 0;}

Running result:



Refer:
1. cv: imread ()
2. Drawing Function of Keypoints and Matches
3. BFMatcher




Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.