Main MRPT website > C++ reference for MRPT 1.5.6
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-2017, 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  /** \addtogroup multidesc_desc Multiresolution SIFTs (experimental)
32  * \ingroup mrpt_vision_grp
33  * @{ */
34 
35  // A 3D quantization table for storing pairs of TFeatureIDs and scales
36  typedef std::map<int,std::map<int,std::map<int,std::deque<std::pair<TFeatureID, double> > > > > TQuantizationTable;
37 
39  const TQuantizationTable & qTable,
40  const std::string & filename );
41 
43  const CFeaturePtr & feat,
44  TQuantizationTable & qTable );
45 
47  const mrpt::utils::CImage & image,
48  CFeatureList & baseList,
49  CFeatureList & currentList,
50  TQuantizationTable & qTable,
51  const TMultiResDescOptions & desc_opts,
52  const TMultiResDescMatchOptions & match_opts );
53 
55  CFeatureList & baseList,
56  const CFeatureList & currentList,
57  const std::vector<int> & idx );
58 
60  CMatchedFeatureList & baseList,
61  const CFeatureList & currentList,
62  const mrpt::utils::CImage & currentImage,
63  const TMultiResMatchingOutput & output,
64  const TMultiResDescOptions & computeOpts,
65  const TMultiResDescMatchOptions & matchOpts );
66 
67  /** Computes the gradient of certain pixel within the image.
68  * \param image [IN] The input image.
69  * \param x [IN] The 'x' coordinate of the image point.
70  * \param y [IN] The 'y' coordinate of the image point.
71  * \param mag [OUT] The magnitude of the gradient.
72  * \param ori [OUT] The orientation of the gradient.
73  * \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)
74  */
76  const mrpt::utils::CImage & image,
77  const unsigned int x,
78  const unsigned int y,
79  double & mag,
80  double & ori );
81 
82  /** 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)
83  * \param image [IN] The input image.
84  * \param x [IN] The 'x' coordinate of the image point.
85  * \param y [IN] The 'y' coordinate of the image point.
86  * \param patchSize [IN] The size of the patch to be considered for computing the orientation histogram.
87  * \param orientations [OUT] A vector containing the main orientations of the image point.
88  * \param sigma [IN] The sigma value of the Gaussian kernel used to smooth the orientation histogram (typically 7.5 px).
89  */
91  const mrpt::utils::CImage & image,
92  const unsigned int x,
93  const unsigned int y,
94  const unsigned int patchSize,
95  std::vector<double> & orientations,
96  const double & sigma );
97 
98  /** Inserts the orientation value of a certain pixel within the keypoint neighbourhood into the histogram of orientations. This value can
99  * affect to more than one entry within the histogram.
100  * \param hist [IN/OUT] The histogram of orientations.
101  * \param cbin [IN] The entry rotated column bin.
102  * \param rbin [IN] The entry rotated row bin.
103  * \param obin [IN] The entry rotated orientation bin.
104  * \param mag [IN] The gradient magnitude value in the pixel.
105  * \param d [IN] The number of row (and column) bins used in the histogram (typically 4).
106  * \param n [IN] The number of orienation bins used in the histogram (typically 8).
107  */
109  std::vector<double> & hist,
110  const double & cbin,
111  const double & rbin,
112  const double & obin,
113  const double & mag,
114  const int d,
115  const int n );
116 
117  /** Computes the SIFT-like descriptor of a certain point within an image at the base scale, i.e. its rotated orientation histogram.
118  * \param image [IN] The input image.
119  * \param x [IN] The 'x' coordinate of the image point.
120  * \param y [IN] The 'y' coordinate of the image point.
121  * \param patchSize [IN] The size of the patch to be considered for computing the orientation histogram.
122  * \param orientation [IN] The orientation considered for this point (used to rotate the patch).
123  * \param orientation [OUT] The computed SIFT-like descriptor.
124  * \param opts [IN] The options for computing the SIFT-like descriptor.
125  * \param hashCoeffs [OUT] A vector containing the computed coefficients for the HASH table used in relocalization.
126  * \sa TMultiResDescOptions
127  */
129  const mrpt::utils::CImage & image,
130  const unsigned int x,
131  const unsigned int y,
132  const unsigned int patchSize,
133  const double & orientation,
134  std::vector<int32_t> & descriptor,
135  const TMultiResDescOptions & opts,
136  std::vector<int32_t> & hashCoeffs );
137 
138  /** Matches two CFeatureList containing mulit-resolution descriptors. The first list is taken as a base, i.e. its features must contain multi-resolution descriptors
139  * 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
140  * the fulfillment of some restriction regarding the matching process. This function will try to find the best matches within list2 corresponding to the features
141  * within base list list1.
142  * \param list1 [IN] The base list of features.
143  * \param list2 [IN/OUT] The other list of features.
144  * \param rightImage [IN] The image from where the list2 was extracted. It's used to compute the descriptor of these features if necessary.
145  * \param output [OUT] The output structure with the matching information.
146  * \param matchOpts [IN] The options structure for the matching process.
147  * \param computeOpts [IN] The options structure for the descriptor computation process.
148  * \return A structure containing the results of the matching.
149  * \sa TMultiResDescMatchOptions, TMultiResDescOptions, TMultiResMatchingOutput
150  */
152  const CFeatureList & list1,
153  CFeatureList & list2,
154  const mrpt::utils::CImage & rightImage,
155  const TMultiResDescMatchOptions & matchOpts,
156  const TMultiResDescOptions & computeOpts );
157 
158  /** Matches two CMatchedFeatureList containing mulit-resolution descriptors. This is performed for both the "left" and "right" lists
159  * The first matched list is taken as a base, i.e. its features must contain multi-resolution descriptors
160  * 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
161  * the fulfillment of some restriction regarding the matching process. This function will try to find the best matches within list2 corresponding to the features
162  * \param mList1 [IN] The base list.
163  * \param mList2 [IN] The other list of features.
164  * \param leftImage [IN] The image from where the list2 was extracted. It's used to compute the descriptor of these features if necessary.
165  * \param rightImage [IN] The image from where the list2 was extracted. It's used to compute the descriptor of these features if necessary.
166  * \param matchOpts [IN] The options structure for the matching process.
167  * \param computeOpts [IN] The options structure for the descriptor computation process.
168  * \return The number of matches found
169  * \sa TMultiResDescMatchOptions
170  */
172  CMatchedFeatureList & mList1,
173  CMatchedFeatureList & mList2,
174  const mrpt::utils::CImage & leftImage,
175  const mrpt::utils::CImage & rightImage,
176  const TMultiResDescMatchOptions & matchOpts,
177  const TMultiResDescOptions & computeOpts );
178 
179  /** Computes more multi-resolution SIFT-like descriptors for a feature using its position in a new image. This
180  * is called when we have found a match between a feature and itself in a new frame but it has been found in
181  * a boundary scale. We now expand the range of scales, orientations and descriptors for that feature.
182  * \param image [IN] The new frame.
183  * \param inputFeat [IN] The feature in the new frame.
184  * \param outputFeat [OUT] The base feature (detected in the base frame).
185  * \param lowerScales [IN] If we should find descriptors for lower scales or for higher ones.
186  * \param opts [IN] The options for computing the new descriptors.
187  */
189  const mrpt::utils::CImage & image,
190  const CFeaturePtr & inputFeat,
191  CFeaturePtr & outputFeat,
192  const bool & lowerScales,
193  const TMultiResDescOptions & opts );
194 
195  /** Computes the initial and final scales where to look when finding a match between multi-resolution features.
196  * Both features must have their "depth" member properly computed.
197  * \param feat1 [IN] The base feature which MUST contain a set of different scales.
198  * \param feat2 [IN] The other feature which must be computed at base scale (1.0).
199  * \param firstScale [OUT] The initial scale (within [0 feat1->multiScale.size()-1]) where to look.
200  * \param firstScale [OUT] The final scale (within [0 feat1->multiScale.size()-1]) where to look.
201  */
203  const CFeaturePtr & feat1,
204  const CFeaturePtr & feat2,
205  int & firstScale,
206  int & lastScale );
207 
208  /** Computes the multi-resolution SIFT-like descriptor of a set of matched features
209  * \param imageLeft [IN] The input left image.
210  * \param imageRight [IN] The input right image.
211  * \param matchedFeats [IN/OUT] The list of matched features. They will be updated with the multi-scales, multi-orientations, multi-descriptors and depth information.
212  * \param opts [IN] The options structure for the descriptor computation process.
213  * \sa TMultiResDescOptions
214  */
216  const mrpt::utils::CImage & imageLeft,
217  const mrpt::utils::CImage & imageRight,
218  CMatchedFeatureList & matchedFeats,
219  const TMultiResDescOptions & opts );
220 
221 
222  /** Computes the multi-resolution SIFT-like descriptor of a features
223  * \param image [IN] The input left image.
224  * \param feat [IN/OUT] The feature. It will be updated with the multi-scales, multi-orientations, multi-descriptors
225  * \param opts [IN] The options structure for the descriptor computation process.
226  * \sa TMultiResDescOptions
227  */
229  const mrpt::utils::CImage & image,
230  CFeaturePtr & feat,
231  const TMultiResDescOptions & opts );
232 
233  /** Computes the multi-resolution SIFT-like descriptor of a list of features
234  * \param image [IN] The input image.
235  * \param list [IN/OUT] The list of features. They will be updated with the multi-scales, multi-orientations and multi-descriptors information.
236  * \param opts [IN] The options structure for the descriptor computation process.
237  * \sa TMultiResDescOptions
238  */
240  const mrpt::utils::CImage & image,
241  CFeatureList & list,
242  const TMultiResDescOptions & opts );
243 
244  /** Computes the multi-resolution SIFT-like descriptor of a list of features
245  * \param image [IN] The input image.
246  * \param list [IN/OUT] The list of features. They will be updated with the multi-scales, multi-orientations and multi-descriptors information.
247  * \param opts [IN] The options structure for the descriptor computation process.
248  * \sa TMultiResDescOptions
249  */
251  const mrpt::utils::CImage & image,
252  CFeatureList & list,
253  const TMultiResDescOptions & opts );
254 
255 
256  /** @} */ // end of grouping
257 
258  }
259 } // end-namespace-mrpt
260 
261 #endif
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...
bool VISION_IMPEXP computeMainOrientations(const mrpt::utils::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...
A class for storing images as grayscale or RGB bitmaps.
Definition: CImage.h:101
void VISION_IMPEXP computeMultiResolutionDescriptors(const mrpt::utils::CImage &imageLeft, const mrpt::utils::CImage &imageRight, CMatchedFeatureList &matchedFeats, const TMultiResDescOptions &opts)
Computes the multi-resolution SIFT-like descriptor of a set of matched features.
GLenum GLsizei n
Definition: glext.h:4618
Struct containing the output after matching multi-resolution SIFT-like descriptors.
bool VISION_IMPEXP computeGradient(const mrpt::utils::CImage &image, const unsigned int x, const unsigned int y, double &mag, double &ori)
Computes the gradient of certain pixel within the image.
GLenum GLsizei GLenum GLenum const GLvoid * image
Definition: glext.h:3522
void VISION_IMPEXP computeHistogramOfOrientations(const mrpt::utils::CImage &image, const unsigned int x, const unsigned int y, const unsigned int patchSize, const double &orientation, std::vector< int32_t > &descriptor, const TMultiResDescOptions &opts, std::vector< int32_t > &hashCoeffs)
Computes the SIFT-like descriptor of a certain point within an image at the base scale, i.e.
TMultiResMatchingOutput VISION_IMPEXP relocalizeMultiDesc(const mrpt::utils::CImage &image, CFeatureList &baseList, CFeatureList &currentList, TQuantizationTable &qTable, const TMultiResDescOptions &desc_opts, const TMultiResDescMatchOptions &match_opts)
void VISION_IMPEXP interpolateHistEntry(std::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...
GLsizei const GLchar ** string
Definition: glext.h:3919
A list of visual features, to be used as output by detectors, as input/output by trackers, etc.
Definition: CFeature.h:211
int VISION_IMPEXP computeMoreDescriptors(const mrpt::utils::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...
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
void VISION_IMPEXP insertHashCoeffs(const CFeaturePtr &feat, TQuantizationTable &qTable)
Struct containing the options when computing the multi-resolution SIFT-like descriptors.
void VISION_IMPEXP updateBaseList(CFeatureList &baseList, const CFeatureList &currentList, const std::vector< int > &idx)
void VISION_IMPEXP saveQTableToFile(const TQuantizationTable &qTable, const std::string &filename)
std::map< int, std::map< int, std::map< int, std::deque< std::pair< TFeatureID, double > > > > > TQuantizationTable
Struct containing the options when matching multi-resolution SIFT-like descriptors.
void VISION_IMPEXP checkScalesAndFindMore(CMatchedFeatureList &baseList, const CFeatureList &currentList, const mrpt::utils::CImage &currentImage, const TMultiResMatchingOutput &output, const TMultiResDescOptions &computeOpts, const TMultiResDescMatchOptions &matchOpts)
GLenum GLint GLint y
Definition: glext.h:3516
void VISION_IMPEXP computeMultiOrientations(const mrpt::utils::CImage &image, CFeatureList &list, const TMultiResDescOptions &opts)
Computes the multi-resolution SIFT-like descriptor of a list of features.
GLenum GLint x
Definition: glext.h:3516
TMultiResMatchingOutput VISION_IMPEXP matchMultiResolutionFeatures(const CFeatureList &list1, CFeatureList &list2, const mrpt::utils::CImage &rightImage, const TMultiResDescMatchOptions &matchOpts, const TMultiResDescOptions &computeOpts)
Matches two CFeatureList containing mulit-resolution descriptors.
A list of features.
Definition: CFeature.h:361



Page generated by Doxygen 1.8.14 for MRPT 1.5.6 Git: 4c65e8431 Tue Apr 24 08:18:17 2018 +0200 at lun oct 28 01:35:26 CET 2019