Book Image

Mastering OpenCV Android Application Programming

Book Image

Mastering OpenCV Android Application Programming

Overview of this book

Table of Contents (16 chapters)
Mastering OpenCV Android Application Programming
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
6
Working with Image Alignment and Stitching
Index

Matching features and detecting objects


Once we have detected features in two or more objects, and have their descriptors, we can match the features to check whether the images have any similarities. For example, suppose we want to search for a particular book in a heap of many books. OpenCV provides us with two feature matching algorithms:

  • Brute-force matcher

  • FLANN based matcher

We will see how the two work in the following sections.

For matching, we first need to declare some variables:

DescriptorMatcher descriptorMatcher;
MatOfDMatch matches = new MatOfDMatch();

Brute-force matcher

It takes the descriptor of one feature in the first set and matches it with all other features in the second set, using distance calculations, and the closest one is returned.

The BF matcher takes two optional parameters. The first one is the distance measurement type, normType. We should use NORM_L2 for descriptors such as SIFT and SURF. For descriptors that are based on a binary string, such as ORB and BRISK, we...