Descriptors describe local image regions and are invariant to image transformations such as rotation, scale or translation. They provide a measure and distance function for a small patch around an interest point. Therefore, whenever the similarity between two image patches needs to be estimated, we compute their descriptors and measure their distance. In OpenCV, the basic Mat type is used to represent a collection of descriptors, where each row is a keypoint descriptor.
There are the following two possibilities to use a feature descriptor extractor:
DescriptorExtractor
common interface(See the following diagram where the descriptors used in this chapter are indicated in red color.)
The common interface allows us to switch easily between different algorithms. This can be very useful when choosing an algorithm to solve a problem, as the results of each algorithm can be compared with no effort. On the other hand, depending on the algorithm, there are several parameters that can be tweaked only using its class.
The Ptr<DescriptorExtractor> DescriptorExtractor::create(const String& descriptorExtractorType)
function creates a new descriptor extractor of the selected type. Descriptors can be grouped in two families: float and binary. Float descriptors store float values in a vector; this can lead to a high memory usage. On the other hand, binary descriptors store binary strings, thus enabling faster processing times and a reduced memory footprint. The current implementation supports the following types:
The other important function of DescriptorExtractor
is void DescriptorExtractor::compute(InputArray image, vector<KeyPoint>& keypoints, OutputArray descriptors)
, which computes the descriptors for a set of keypoints detected in an image on the previous step. There is a variant of the function that accepts an image set.