Main MRPT website > C++ reference
MRPT logo
multiDesc_utils.h
Go to the documentation of this file.
1  /* +---------------------------------------------------------------------------+
2  | The Mobile Robot Programming Toolkit (MRPT) C++ library |
3  | |
4  | http://www.mrpt.org/ |
5  | |
6  | Copyright (C) 2005-2012 University of Malaga |
7  | |
8  | This software was written by the Machine Perception and Intelligent |
9  | Robotics Lab, University of Malaga (Spain). |
10  | Contact: Jose-Luis Blanco <jlblanco@ctima.uma.es> |
11  | |
12  | This file is part of the MRPT project. |
13  | |
14  | MRPT is free software: you can redistribute it and/or modify |
15  | it under the terms of the GNU General Public License as published by |
16  | the Free Software Foundation, either version 3 of the License, or |
17  | (at your option) any later version. |
18  | |
19  | MRPT is distributed in the hope that it will be useful, |
20  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
21  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
22  | GNU General Public License for more details. |
23  | |
24  | You should have received a copy of the GNU General Public License |
25  | along with MRPT. If not, see <http://www.gnu.org/licenses/>. |
26  | |
27  +---------------------------------------------------------------------------+ */
28 
29 #ifndef mrpt_multiDesc_utils_H
30 #define mrpt_multiDesc_utils_H
31 
32 #include <mrpt/vision/CFeature.h>
33 #include <mrpt/utils/CImage.h>
34 #include <mrpt/math/utils.h>
37 #include <mrpt/poses/CPose3D.h>
38 #include <mrpt/poses/CPoint2D.h>
39 #include <mrpt/poses/CPoint3D.h>
42 
43 #include <mrpt/vision/types.h>
45 
47 
48 namespace mrpt
49 {
50  namespace vision
51  {
52  using namespace std;
53  using namespace mrpt::slam;
54  using namespace mrpt::math;
55  using namespace mrpt::utils;
56 
57  /** \addtogroup multidesc_desc Multiresolution SIFTs (experimental)
58  * \ingroup mrpt_vision_grp
59  * @{ */
60 
61  // A 3D quantization table for storing pairs of TFeatureIDs and scales
62  typedef map<int,map<int,map<int,deque<pair<TFeatureID, double> > > > > TQuantizationTable;
63 
65  const TQuantizationTable & qTable,
66  const string & filename );
67 
69  const CFeaturePtr & feat,
70  TQuantizationTable & qTable );
71 
73  const CImage & image,
74  CFeatureList & baseList,
75  CFeatureList & currentList,
76  TQuantizationTable & qTable,
77  const TMultiResDescOptions & desc_opts,
78  const TMultiResDescMatchOptions & match_opts );
79 
81  CFeatureList & baseList,
82  const CFeatureList & currentList,
83  const vector<int> & idx );
84 
86  CMatchedFeatureList & baseList,
87  const CFeatureList & currentList,
88  const CImage & currentImage,
89  const TMultiResMatchingOutput & output,
90  const TMultiResDescOptions & computeOpts,
91  const TMultiResDescMatchOptions & matchOpts );
92 
93  /** Computes the gradient of certain pixel within the image.
94  * \param image [IN] The input image.
95  * \param x [IN] The 'x' coordinate of the image point.
96  * \param y [IN] The 'y' coordinate of the image point.
97  * \param mag [OUT] The magnitude of the gradient.
98  * \param ori [OUT] The orientation of the gradient.
99  * \return True if the gradient could be computed and False if the pixel is located outside the image or at its border (where the gradient cannot be computed)
100  */
102  const CImage & image,
103  const unsigned int x,
104  const unsigned int y,
105  double & mag,
106  double & ori );
107 
108  /** Computes the main orientations (within 80% of the peak value of orientation histogram) of a certain point within an image (for using in SIFT-based algorithms)
109  * \param image [IN] The input image.
110  * \param x [IN] The 'x' coordinate of the image point.
111  * \param y [IN] The 'y' coordinate of the image point.
112  * \param patchSize [IN] The size of the patch to be considered for computing the orientation histogram.
113  * \param orientations [OUT] A vector containing the main orientations of the image point.
114  * \param sigma [IN] The sigma value of the Gaussian kernel used to smooth the orientation histogram (typically 7.5 px).
115  */
117  const CImage & image,
118  const unsigned int x,
119  const unsigned int y,
120  const unsigned int patchSize,
121  std::vector<double> & orientations,
122  const double & sigma );
123 
124  /** Inserts the orientation value of a certain pixel within the keypoint neighbourhood into the histogram of orientations. This value can
125  * affect to more than one entry within the histogram.
126  * \param hist [IN/OUT] The histogram of orientations.
127  * \param cbin [IN] The entry rotated column bin.
128  * \param rbin [IN] The entry rotated row bin.
129  * \param obin [IN] The entry rotated orientation bin.
130  * \param mag [IN] The gradient magnitude value in the pixel.
131  * \param d [IN] The number of row (and column) bins used in the histogram (typically 4).
132  * \param n [IN] The number of orienation bins used in the histogram (typically 8).
133  */
135  vector<double> & hist,
136  const double & cbin,
137  const double & rbin,
138  const double & obin,
139  const double & mag,
140  const int d,
141  const int n );
142 
143  /** Computes the SIFT-like descriptor of a certain point within an image at the base scale, i.e. its rotated orientation histogram.
144  * \param image [IN] The input image.
145  * \param x [IN] The 'x' coordinate of the image point.
146  * \param y [IN] The 'y' coordinate of the image point.
147  * \param patchSize [IN] The size of the patch to be considered for computing the orientation histogram.
148  * \param orientation [IN] The orientation considered for this point (used to rotate the patch).
149  * \param orientation [OUT] The computed SIFT-like descriptor.
150  * \param opts [IN] The options for computing the SIFT-like descriptor.
151  * \param hashCoeffs [OUT] A vector containing the computed coefficients for the HASH table used in relocalization.
152  * \sa TMultiResDescOptions
153  */
155  const CImage & image,
156  const unsigned int x,
157  const unsigned int y,
158  const unsigned int patchSize,
159  const double & orientation,
160  vector<int32_t> & descriptor,
161  const TMultiResDescOptions & opts,
162  vector<int32_t> & hashCoeffs );
163 
164  /** Matches two CFeatureList containing mulit-resolution descriptors. The first list is taken as a base, i.e. its features must contain multi-resolution descriptors
165  * at a set of different scales. The second list doesn't need to contain such information because it will be computed if necessary according to the
166  * the fulfillment of some restriction regarding the matching process. This function will try to find the best matches within list2 corresponding to the features
167  * within base list list1.
168  * \param list1 [IN] The base list of features.
169  * \param list2 [IN/OUT] The other list of features.
170  * \param rightImage [IN] The image from where the list2 was extracted. It's used to compute the descriptor of these features if necessary.
171  * \param output [OUT] The output structure with the matching information.
172  * \param matchOpts [IN] The options structure for the matching process.
173  * \param computeOpts [IN] The options structure for the descriptor computation process.
174  * \return A structure containing the results of the matching.
175  * \sa TMultiResDescMatchOptions, TMultiResDescOptions, TMultiResMatchingOutput
176  */
178  const CFeatureList & list1,
179  CFeatureList & list2,
180  const CImage & rightImage,
181  const TMultiResDescMatchOptions & matchOpts,
182  const TMultiResDescOptions & computeOpts );
183 
184  /** Matches two CMatchedFeatureList containing mulit-resolution descriptors. This is performed for both the "left" and "right" lists
185  * The first matched list is taken as a base, i.e. its features must contain multi-resolution descriptors
186  * at a set of different scales. The second list doesn't need to contain such information because it will be computed if necessary according to the
187  * the fulfillment of some restriction regarding the matching process. This function will try to find the best matches within list2 corresponding to the features
188  * \param mList1 [IN] The base list.
189  * \param mList2 [IN] The other list of features.
190  * \param leftImage [IN] The image from where the list2 was extracted. It's used to compute the descriptor of these features if necessary.
191  * \param rightImage [IN] The image from where the list2 was extracted. It's used to compute the descriptor of these features if necessary.
192  * \param matchOpts [IN] The options structure for the matching process.
193  * \param computeOpts [IN] The options structure for the descriptor computation process.
194  * \return The number of matches found
195  * \sa TMultiResDescMatchOptions
196  */
198  CMatchedFeatureList & mList1,
199  CMatchedFeatureList & mList2,
200  const CImage & leftImage,
201  const CImage & rightImage,
202  const TMultiResDescMatchOptions & matchOpts,
203  const TMultiResDescOptions & computeOpts );
204 
205  /** Computes more multi-resolution SIFT-like descriptors for a feature using its position in a new image. This
206  * is called when we have found a match between a feature and itself in a new frame but it has been found in
207  * a boundary scale. We now expand the range of scales, orientations and descriptors for that feature.
208  * \param image [IN] The new frame.
209  * \param inputFeat [IN] The feature in the new frame.
210  * \param outputFeat [OUT] The base feature (detected in the base frame).
211  * \param lowerScales [IN] If we should find descriptors for lower scales or for higher ones.
212  * \param opts [IN] The options for computing the new descriptors.
213  */
215  const CImage & image,
216  const CFeaturePtr & inputFeat,
217  CFeaturePtr & outputFeat,
218  const bool & lowerScales,
219  const TMultiResDescOptions & opts );
220 
221  /** Computes the initial and final scales where to look when finding a match between multi-resolution features.
222  * Both features must have their "depth" member properly computed.
223  * \param feat1 [IN] The base feature which MUST contain a set of different scales.
224  * \param feat2 [IN] The other feature which must be computed at base scale (1.0).
225  * \param firstScale [OUT] The initial scale (within [0 feat1->multiScale.size()-1]) where to look.
226  * \param firstScale [OUT] The final scale (within [0 feat1->multiScale.size()-1]) where to look.
227  */
229  const CFeaturePtr & feat1,
230  const CFeaturePtr & feat2,
231  int & firstScale,
232  int & lastScale );
233 
234  /** Computes the multi-resolution SIFT-like descriptor of a set of matched features
235  * \param imageLeft [IN] The input left image.
236  * \param imageRight [IN] The input right image.
237  * \param matchedFeats [IN/OUT] The list of matched features. They will be updated with the multi-scales, multi-orientations, multi-descriptors and depth information.
238  * \param opts [IN] The options structure for the descriptor computation process.
239  * \sa TMultiResDescOptions
240  */
242  const CImage & imageLeft,
243  const CImage & imageRight,
244  CMatchedFeatureList & matchedFeats,
245  const TMultiResDescOptions & opts );
246 
247 
248  /** Computes the multi-resolution SIFT-like descriptor of a features
249  * \param image [IN] The input left image.
250  * \param feat [IN/OUT] The feature. It will be updated with the multi-scales, multi-orientations, multi-descriptors
251  * \param opts [IN] The options structure for the descriptor computation process.
252  * \sa TMultiResDescOptions
253  */
255  const CImage & image,
256  CFeaturePtr & feat,
257  const TMultiResDescOptions & opts );
258 
259  /** Computes the multi-resolution SIFT-like descriptor of a list of features
260  * \param image [IN] The input image.
261  * \param list [IN/OUT] The list of features. They will be updated with the multi-scales, multi-orientations and multi-descriptors information.
262  * \param opts [IN] The options structure for the descriptor computation process.
263  * \sa TMultiResDescOptions
264  */
266  const CImage & image,
267  CFeatureList & list,
268  const TMultiResDescOptions & opts );
269 
270  /** Computes the multi-resolution SIFT-like descriptor of a list of features
271  * \param image [IN] The input image.
272  * \param list [IN/OUT] The list of features. They will be updated with the multi-scales, multi-orientations and multi-descriptors information.
273  * \param opts [IN] The options structure for the descriptor computation process.
274  * \sa TMultiResDescOptions
275  */
277  const CImage & image,
278  CFeatureList & list,
279  const TMultiResDescOptions & opts );
280 
281 
282  /** @} */ // end of grouping
283 
284  }
285 } // end-namespace-mrpt
286 
287 #endif



Page generated by Doxygen 1.8.3 for MRPT 0.9.6 SVN: at Fri Feb 15 22:05:02 EST 2013