Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to use OpenCV to realize BFMatcher matching in C++

Shulou Source: shulou.com Published: 2022-06-02 08:08:12 12月01日 Update

C++ how to use OpenCV to achieve BFMatcher matching, I believe that many inexperienced people do not know what to do, so this paper summarizes the causes of the problem and solutions, through this article I hope you can solve this problem.

Realization principle

It is found that M feature vectors are extracted from the two images respectively.

Then the feature vectors of N and M are matched to find the best match.

And then draw matching features to show them.

Code demonstration

Let's create a new project named opencv--brief, follow the configuration properties (VS2017 configure OpenCV common properties), and then write # include and main methods in the source file

We read two pictures directly for processing.

Then we see the operation of BFMatch:

1. First of all, we convert the picture into a grayscale image, and the converted grayscale image is still using our original definition of src1 and src2.

two。 By using the feature detection of Surf, we put the KeyPoint we obtained from the two images into the corresponding descriptor.

3. According to the two Mat of descriptor extracted in the previous step, the best match is made through BFMatcher and stored in a DMatch defined by us.

4. In the last step, we first define an output image img_mathces, then draw the Matches of the feature points and the matching results in the two pictures by drawMatches method, and finally display the picture we have drawn by imshow method.

After reading the above, have you mastered how to use OpenCV to achieve BFMatcher matching in C++? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel, thank you for reading!

Tags: Pictures methods features two clocked images content vectors attributes more grayscale problems configuration helpless for this code reasons principles images this skills Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MariaDB Redmi Shulou Information MySQL NVidia