CLAHE Python bindings
[profile/ivi/opencv.git] / modules / features2d / doc / common_interfaces_of_descriptor_extractors.rst
1 Common Interfaces of Descriptor Extractors
2 ==========================================
3
4 .. highlight:: cpp
5
6 Extractors of keypoint descriptors in OpenCV have wrappers with a common interface that enables you to easily switch
7 between different algorithms solving the same problem. This section is devoted to computing descriptors
8 represented as vectors in a multidimensional space. All objects that implement the ``vector``
9 descriptor extractors inherit the
10 :ocv:class:`DescriptorExtractor` interface.
11
12
13
14 DescriptorExtractor
15 -------------------
16 .. ocv:class:: DescriptorExtractor : public Algorithm
17
18 Abstract base class for computing descriptors for image keypoints. ::
19
20     class CV_EXPORTS DescriptorExtractor
21     {
22     public:
23         virtual ~DescriptorExtractor();
24
25         void compute( const Mat& image, vector<KeyPoint>& keypoints,
26                       Mat& descriptors ) const;
27         void compute( const vector<Mat>& images, vector<vector<KeyPoint> >& keypoints,
28                       vector<Mat>& descriptors ) const;
29
30         virtual void read( const FileNode& );
31         virtual void write( FileStorage& ) const;
32
33         virtual int descriptorSize() const = 0;
34         virtual int descriptorType() const = 0;
35
36         static Ptr<DescriptorExtractor> create( const string& descriptorExtractorType );
37
38     protected:
39         ...
40     };
41
42
43 In this interface, a keypoint descriptor can be represented as a
44 dense, fixed-dimension vector of a basic type. Most descriptors
45 follow this pattern as it simplifies computing
46 distances between descriptors. Therefore, a collection of
47 descriptors is represented as
48 :ocv:class:`Mat` , where each row is a keypoint descriptor.
49
50
51
52 DescriptorExtractor::compute
53 --------------------------------
54 Computes the descriptors for a set of keypoints detected in an image (first variant) or image set (second variant).
55
56 .. ocv:function:: void DescriptorExtractor::compute( const Mat& image, vector<KeyPoint>& keypoints, Mat& descriptors ) const
57
58 .. ocv:function:: void DescriptorExtractor::compute( const vector<Mat>& images, vector<vector<KeyPoint> >& keypoints, vector<Mat>& descriptors ) const
59
60     :param image: Image.
61
62     :param images: Image set.
63
64     :param keypoints: Input collection of keypoints. Keypoints for which a descriptor cannot be computed are removed. Sometimes new keypoints can be added, for example: ``SIFT`` duplicates keypoint with several dominant orientations (for each orientation).
65
66     :param descriptors: Computed descriptors. In the second variant of the method ``descriptors[i]`` are descriptors computed for a ``keypoints[i]`. Row ``j`` is the ``keypoints`` (or ``keypoints[i]``) is the descriptor for keypoint ``j``-th keypoint.
67
68
69 DescriptorExtractor::create
70 -------------------------------
71 Creates a descriptor extractor by name.
72
73 .. ocv:function:: Ptr<DescriptorExtractor>  DescriptorExtractor::create( const string& descriptorExtractorType )
74
75     :param descriptorExtractorType: Descriptor extractor type.
76
77 The current implementation supports the following types of a descriptor extractor:
78
79  * ``"SIFT"`` -- :ocv:class:`SIFT`
80  * ``"SURF"`` -- :ocv:class:`SURF`
81  * ``"ORB"`` -- :ocv:class:`ORB`
82  * ``"BRISK"`` -- :ocv:class:`BRISK`
83  * ``"BRIEF"`` -- :ocv:class:`BriefDescriptorExtractor`
84
85 A combined format is also supported: descriptor extractor adapter name ( ``"Opponent"`` --
86 :ocv:class:`OpponentColorDescriptorExtractor` ) + descriptor extractor name (see above),
87 for example: ``"OpponentSIFT"`` .
88
89
90 OpponentColorDescriptorExtractor
91 --------------------------------
92 .. ocv:class:: OpponentColorDescriptorExtractor : public DescriptorExtractor
93
94 Class adapting a descriptor extractor to compute descriptors in the Opponent Color Space
95 (refer to Van de Sande et al., CGIV 2008 *Color Descriptors for Object Category Recognition*).
96 Input RGB image is transformed in the Opponent Color Space. Then, an unadapted descriptor extractor
97 (set in the constructor) computes descriptors on each of three channels and concatenates
98 them into a single color descriptor. ::
99
100     class OpponentColorDescriptorExtractor : public DescriptorExtractor
101     {
102     public:
103         OpponentColorDescriptorExtractor( const Ptr<DescriptorExtractor>& dextractor );
104
105         virtual void read( const FileNode& );
106         virtual void write( FileStorage& ) const;
107         virtual int descriptorSize() const;
108         virtual int descriptorType() const;
109     protected:
110         ...
111     };
112
113
114
115 BriefDescriptorExtractor
116 ------------------------
117 .. ocv:class:: BriefDescriptorExtractor : public DescriptorExtractor
118
119 Class for computing BRIEF descriptors described in a paper of Calonder M., Lepetit V.,
120 Strecha C., Fua P. *BRIEF: Binary Robust Independent Elementary Features* ,
121 11th European Conference on Computer Vision (ECCV), Heraklion, Crete. LNCS Springer, September 2010. ::
122
123     class BriefDescriptorExtractor : public DescriptorExtractor
124     {
125     public:
126         static const int PATCH_SIZE = 48;
127         static const int KERNEL_SIZE = 9;
128
129         // bytes is a length of descriptor in bytes. It can be equal 16, 32 or 64 bytes.
130         BriefDescriptorExtractor( int bytes = 32 );
131
132         virtual void read( const FileNode& );
133         virtual void write( FileStorage& ) const;
134         virtual int descriptorSize() const;
135         virtual int descriptorType() const;
136     protected:
137         ...
138     };
139
140