Main MRPT website > C++ reference
MRPT logo
multiDesc_utils.h
Go to the documentation of this file.
1 /* +---------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | http://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2014, Individual contributors, see AUTHORS file |
6  | See: http://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See details in http://www.mrpt.org/License |
8  +---------------------------------------------------------------------------+ */
9 
10 #ifndef mrpt_multiDesc_utils_H
11 #define mrpt_multiDesc_utils_H
12 
13 #include <mrpt/vision/CFeature.h>
14 #include <mrpt/utils/CImage.h>
15 #include <mrpt/math/utils.h>
18 #include <mrpt/poses/CPose3D.h>
21 
22 #include <mrpt/vision/types.h>
24 
26 
27 namespace mrpt
28 {
29  namespace vision
30  {
31  using namespace std;
32  using namespace mrpt::slam;
33  using namespace mrpt::math;
34  using namespace mrpt::utils;
35 
36  /** \addtogroup multidesc_desc Multiresolution SIFTs (experimental)
37  * \ingroup mrpt_vision_grp
38  * @{ */
39 
40  // A 3D quantization table for storing pairs of TFeatureIDs and scales
41  typedef map<int,map<int,map<int,deque<pair<TFeatureID, double> > > > > TQuantizationTable;
42 
44  const TQuantizationTable & qTable,
45  const string & filename );
46 
48  const CFeaturePtr & feat,
49  TQuantizationTable & qTable );
50 
52  const CImage & image,
53  CFeatureList & baseList,
54  CFeatureList & currentList,
55  TQuantizationTable & qTable,
56  const TMultiResDescOptions & desc_opts,
57  const TMultiResDescMatchOptions & match_opts );
58 
60  CFeatureList & baseList,
61  const CFeatureList & currentList,
62  const vector<int> & idx );
63 
65  CMatchedFeatureList & baseList,
66  const CFeatureList & currentList,
67  const CImage & currentImage,
68  const TMultiResMatchingOutput & output,
69  const TMultiResDescOptions & computeOpts,
70  const TMultiResDescMatchOptions & matchOpts );
71 
72  /** Computes the gradient of certain pixel within the image.
73  * \param image [IN] The input image.
74  * \param x [IN] The 'x' coordinate of the image point.
75  * \param y [IN] The 'y' coordinate of the image point.
76  * \param mag [OUT] The magnitude of the gradient.
77  * \param ori [OUT] The orientation of the gradient.
78  * \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)
79  */
81  const CImage & image,
82  const unsigned int x,
83  const unsigned int y,
84  double & mag,
85  double & ori );
86 
87  /** 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)
88  * \param image [IN] The input image.
89  * \param x [IN] The 'x' coordinate of the image point.
90  * \param y [IN] The 'y' coordinate of the image point.
91  * \param patchSize [IN] The size of the patch to be considered for computing the orientation histogram.
92  * \param orientations [OUT] A vector containing the main orientations of the image point.
93  * \param sigma [IN] The sigma value of the Gaussian kernel used to smooth the orientation histogram (typically 7.5 px).
94  */
96  const CImage & image,
97  const unsigned int x,
98  const unsigned int y,
99  const unsigned int patchSize,
100  std::vector<double> & orientations,
101  const double & sigma );
102 
103  /** Inserts the orientation value of a certain pixel within the keypoint neighbourhood into the histogram of orientations. This value can
104  * affect to more than one entry within the histogram.
105  * \param hist [IN/OUT] The histogram of orientations.
106  * \param cbin [IN] The entry rotated column bin.
107  * \param rbin [IN] The entry rotated row bin.
108  * \param obin [IN] The entry rotated orientation bin.
109  * \param mag [IN] The gradient magnitude value in the pixel.
110  * \param d [IN] The number of row (and column) bins used in the histogram (typically 4).
111  * \param n [IN] The number of orienation bins used in the histogram (typically 8).
112  */
114  vector<double> & hist,
115  const double & cbin,
116  const double & rbin,
117  const double & obin,
118  const double & mag,
119  const int d,
120  const int n );
121 
122  /** Computes the SIFT-like descriptor of a certain point within an image at the base scale, i.e. its rotated orientation histogram.
123  * \param image [IN] The input image.
124  * \param x [IN] The 'x' coordinate of the image point.
125  * \param y [IN] The 'y' coordinate of the image point.
126  * \param patchSize [IN] The size of the patch to be considered for computing the orientation histogram.
127  * \param orientation [IN] The orientation considered for this point (used to rotate the patch).
128  * \param orientation [OUT] The computed SIFT-like descriptor.
129  * \param opts [IN] The options for computing the SIFT-like descriptor.
130  * \param hashCoeffs [OUT] A vector containing the computed coefficients for the HASH table used in relocalization.
131  * \sa TMultiResDescOptions
132  */
134  const CImage & image,
135  const unsigned int x,
136  const unsigned int y,
137  const unsigned int patchSize,
138  const double & orientation,
139  vector<int32_t> & descriptor,
140  const TMultiResDescOptions & opts,
141  vector<int32_t> & hashCoeffs );
142 
143  /** Matches two CFeatureList containing mulit-resolution descriptors. The first list is taken as a base, i.e. its features must contain multi-resolution descriptors
144  * 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
145  * the fulfillment of some restriction regarding the matching process. This function will try to find the best matches within list2 corresponding to the features
146  * within base list list1.
147  * \param list1 [IN] The base list of features.
148  * \param list2 [IN/OUT] The other list of features.
149  * \param rightImage [IN] The image from where the list2 was extracted. It's used to compute the descriptor of these features if necessary.
150  * \param output [OUT] The output structure with the matching information.
151  * \param matchOpts [IN] The options structure for the matching process.
152  * \param computeOpts [IN] The options structure for the descriptor computation process.
153  * \return A structure containing the results of the matching.
154  * \sa TMultiResDescMatchOptions, TMultiResDescOptions, TMultiResMatchingOutput
155  */
157  const CFeatureList & list1,
158  CFeatureList & list2,
159  const CImage & rightImage,
160  const TMultiResDescMatchOptions & matchOpts,
161  const TMultiResDescOptions & computeOpts );
162 
163  /** Matches two CMatchedFeatureList containing mulit-resolution descriptors. This is performed for both the "left" and "right" lists
164  * The first matched 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  * \param mList1 [IN] The base list.
168  * \param mList2 [IN] The other list of features.
169  * \param leftImage [IN] The image from where the list2 was extracted. It's used to compute the descriptor of these features if necessary.
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 matchOpts [IN] The options structure for the matching process.
172  * \param computeOpts [IN] The options structure for the descriptor computation process.
173  * \return The number of matches found
174  * \sa TMultiResDescMatchOptions
175  */
177  CMatchedFeatureList & mList1,
178  CMatchedFeatureList & mList2,
179  const CImage & leftImage,
180  const CImage & rightImage,
181  const TMultiResDescMatchOptions & matchOpts,
182  const TMultiResDescOptions & computeOpts );
183 
184  /** Computes more multi-resolution SIFT-like descriptors for a feature using its position in a new image. This
185  * is called when we have found a match between a feature and itself in a new frame but it has been found in
186  * a boundary scale. We now expand the range of scales, orientations and descriptors for that feature.
187  * \param image [IN] The new frame.
188  * \param inputFeat [IN] The feature in the new frame.
189  * \param outputFeat [OUT] The base feature (detected in the base frame).
190  * \param lowerScales [IN] If we should find descriptors for lower scales or for higher ones.
191  * \param opts [IN] The options for computing the new descriptors.
192  */
194  const CImage & image,
195  const CFeaturePtr & inputFeat,
196  CFeaturePtr & outputFeat,
197  const bool & lowerScales,
198  const TMultiResDescOptions & opts );
199 
200  /** Computes the initial and final scales where to look when finding a match between multi-resolution features.
201  * Both features must have their "depth" member properly computed.
202  * \param feat1 [IN] The base feature which MUST contain a set of different scales.
203  * \param feat2 [IN] The other feature which must be computed at base scale (1.0).
204  * \param firstScale [OUT] The initial scale (within [0 feat1->multiScale.size()-1]) where to look.
205  * \param firstScale [OUT] The final scale (within [0 feat1->multiScale.size()-1]) where to look.
206  */
208  const CFeaturePtr & feat1,
209  const CFeaturePtr & feat2,
210  int & firstScale,
211  int & lastScale );
212 
213  /** Computes the multi-resolution SIFT-like descriptor of a set of matched features
214  * \param imageLeft [IN] The input left image.
215  * \param imageRight [IN] The input right image.
216  * \param matchedFeats [IN/OUT] The list of matched features. They will be updated with the multi-scales, multi-orientations, multi-descriptors and depth information.
217  * \param opts [IN] The options structure for the descriptor computation process.
218  * \sa TMultiResDescOptions
219  */
221  const CImage & imageLeft,
222  const CImage & imageRight,
223  CMatchedFeatureList & matchedFeats,
224  const TMultiResDescOptions & opts );
225 
226 
227  /** Computes the multi-resolution SIFT-like descriptor of a features
228  * \param image [IN] The input left image.
229  * \param feat [IN/OUT] The feature. It will be updated with the multi-scales, multi-orientations, multi-descriptors
230  * \param opts [IN] The options structure for the descriptor computation process.
231  * \sa TMultiResDescOptions
232  */
234  const CImage & image,
235  CFeaturePtr & feat,
236  const TMultiResDescOptions & opts );
237 
238  /** Computes the multi-resolution SIFT-like descriptor of a list of features
239  * \param image [IN] The input image.
240  * \param list [IN/OUT] The list of features. They will be updated with the multi-scales, multi-orientations and multi-descriptors information.
241  * \param opts [IN] The options structure for the descriptor computation process.
242  * \sa TMultiResDescOptions
243  */
245  const CImage & image,
246  CFeatureList & list,
247  const TMultiResDescOptions & opts );
248 
249  /** Computes the multi-resolution SIFT-like descriptor of a list of features
250  * \param image [IN] The input image.
251  * \param list [IN/OUT] The list of features. They will be updated with the multi-scales, multi-orientations and multi-descriptors information.
252  * \param opts [IN] The options structure for the descriptor computation process.
253  * \sa TMultiResDescOptions
254  */
256  const CImage & image,
257  CFeatureList & list,
258  const TMultiResDescOptions & opts );
259 
260 
261  /** @} */ // end of grouping
262 
263  }
264 } // end-namespace-mrpt
265 
266 #endif
Classes for serialization, sockets, ini-file manipulation, streams, list of properties-values, timewatch, extensions to STL.
Definition: zip.h:16
int VISION_IMPEXP computeMoreDescriptors(const CImage &image, const CFeaturePtr &inputFeat, CFeaturePtr &outputFeat, const bool &lowerScales, const TMultiResDescOptions &opts)
Computes more multi-resolution SIFT-like descriptors for a feature using its position in a new image...
void VISION_IMPEXP computeHistogramOfOrientations(const CImage &image, const unsigned int x, const unsigned int y, const unsigned int patchSize, const double &orientation, vector< int32_t > &descriptor, const TMultiResDescOptions &opts, vector< int32_t > &hashCoeffs)
Computes the SIFT-like descriptor of a certain point within an image at the base scale, i.e.
A class for storing images as grayscale or RGB bitmaps.
Definition: CImage.h:97
void VISION_IMPEXP saveQTableToFile(const TQuantizationTable &qTable, const string &filename)
TMultiResMatchingOutput VISION_IMPEXP matchMultiResolutionFeatures(const CFeatureList &list1, CFeatureList &list2, const CImage &rightImage, const TMultiResDescMatchOptions &matchOpts, const TMultiResDescOptions &computeOpts)
Matches two CFeatureList containing mulit-resolution descriptors.
Struct containing the output after matching multi-resolution SIFT-like descriptors.
STL namespace.
void VISION_IMPEXP computeMultiOrientations(const CImage &image, CFeatureList &list, const TMultiResDescOptions &opts)
Computes the multi-resolution SIFT-like descriptor of a list of features.
bool VISION_IMPEXP computeGradient(const CImage &image, const unsigned int x, const unsigned int y, double &mag, double &ori)
Computes the gradient of certain pixel within the image.
This namespace contains algorithms for SLAM, localization, map building, representation of robot's ac...
void VISION_IMPEXP insertHashCoeffs(const CFeaturePtr &feat, TQuantizationTable &qTable)
This base provides a set of functions for maths stuff.
Definition: CArray.h:18
void VISION_IMPEXP interpolateHistEntry(vector< double > &hist, const double &cbin, const double &rbin, const double &obin, const double &mag, const int d, const int n)
Inserts the orientation value of a certain pixel within the keypoint neighbourhood into the histogram...
void VISION_IMPEXP updateBaseList(CFeatureList &baseList, const CFeatureList &currentList, const vector< int > &idx)
bool VISION_IMPEXP computeMainOrientations(const CImage &image, const unsigned int x, const unsigned int y, const unsigned int patchSize, std::vector< double > &orientations, const double &sigma)
Computes the main orientations (within 80% of the peak value of orientation histogram) of a certain p...
void VISION_IMPEXP checkScalesAndFindMore(CMatchedFeatureList &baseList, const CFeatureList &currentList, const CImage &currentImage, const TMultiResMatchingOutput &output, const TMultiResDescOptions &computeOpts, const TMultiResDescMatchOptions &matchOpts)
A list of visual features, to be used as output by detectors, as input/output by trackers, etc.
Definition: CFeature.h:215
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
Struct containing the options when computing the multi-resolution SIFT-like descriptors.
void VISION_IMPEXP computeMultiResolutionDescriptors(const CImage &imageLeft, const CImage &imageRight, CMatchedFeatureList &matchedFeats, const TMultiResDescOptions &opts)
Computes the multi-resolution SIFT-like descriptor of a set of matched features.
Struct containing the options when matching multi-resolution SIFT-like descriptors.
void VISION_IMPEXP setProperScales(const CFeaturePtr &feat1, const CFeaturePtr &feat2, int &firstScale, int &lastScale)
Computes the initial and final scales where to look when finding a match between multi-resolution fea...
TMultiResMatchingOutput VISION_IMPEXP relocalizeMultiDesc(const CImage &image, CFeatureList &baseList, CFeatureList &currentList, TQuantizationTable &qTable, const TMultiResDescOptions &desc_opts, const TMultiResDescMatchOptions &match_opts)
map< int, map< int, map< int, deque< pair< TFeatureID, double > > > > > TQuantizationTable
A list of features.
Definition: CFeature.h:365



Page generated by Doxygen 1.8.8 for MRPT 1.2.2 SVN:Unversioned directory at Tue Oct 14 02:14:08 UTC 2014