How to use OpenCV to realize BFMatcher matching in C++
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!