Main MRPT website > C++ reference for MRPT 1.9.9
CFeatureExtraction_logPolarImg.cpp
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 #include "vision-precomp.h" // Precompiled headers
11 
13 
14 // Universal include for all versions of OpenCV
15 #include <mrpt/otherlibs/do_opencv_includes.h>
16 
17 using namespace mrpt;
18 using namespace mrpt::vision;
19 using namespace mrpt::system;
20 using namespace std;
21 
22 /************************************************************************************************
23  computeLogPolarImageDescriptors
24 ************************************************************************************************/
26  const mrpt::utils::CImage& in_img, CFeatureList& in_features) const
27 {
29 #if MRPT_HAS_OPENCV
30 
31  ASSERT_(options.LogPolarImagesOptions.radius > 1)
32  ASSERT_(options.LogPolarImagesOptions.num_angles > 1)
33  ASSERT_(options.LogPolarImagesOptions.rho_scale > 0)
34 
35  const unsigned int radius = options.LogPolarImagesOptions.radius;
36  const unsigned int patch_h = options.LogPolarImagesOptions.num_angles;
37  const double rho_scale = options.LogPolarImagesOptions.rho_scale;
38  const unsigned int patch_w =
39  rho_scale * std::log(static_cast<double>(radius));
40 
41  mrpt::utils::CImage logpolar_frame(
42  patch_w, patch_h, in_img.getChannelCount());
43 
44  // Compute intensity-domain spin images
45  for (CFeatureList::iterator it = in_features.begin();
46  it != in_features.end(); ++it)
47  {
48  // Overwrite scale with the descriptor scale:
49  (*it)->scale = radius;
50 
51  // Use OpenCV to convert:
52  cvLogPolar(
53  in_img.getAs<IplImage>(), logpolar_frame.getAs<IplImage>(),
54  cvPoint2D32f((*it)->x, (*it)->y), rho_scale,
55  CV_INTER_LINEAR + CV_WARP_FILL_OUTLIERS);
56 
57  // Get the image as a matrix and save as patch:
58  logpolar_frame.getAsMatrix((*it)->descriptors.LogPolarImg);
59 
60  } // end for it
61 
62 #else
63  THROW_EXCEPTION("This method needs MRPT compiled with OpenCV support")
64 #endif
65  MRPT_END
66 }
TImageChannels getChannelCount() const
Returns the number of channels, typically 1 (GRAY) or 3 (RGB)
Definition: CImage.cpp:925
This namespace provides a OS-independent interface to many useful functions: filenames manipulation...
Definition: math_frwds.h:30
A class for storing images as grayscale or RGB bitmaps.
Definition: CImage.h:118
#define THROW_EXCEPTION(msg)
void internal_computeLogPolarImageDescriptors(const mrpt::utils::CImage &in_img, CFeatureList &in_features) const
Compute a log-polar image descriptor of the provided features into the input image.
STL namespace.
const T * getAs() const
Returns a pointer to a const T* containing the image - the idea is to call like "img.getAs<IplImage>()" so we can avoid here including OpenCV&#39;s headers.
Definition: CImage.h:587
#define MRPT_END
Classes for computer vision, detectors, features, etc.
A list of visual features, to be used as output by detectors, as input/output by trackers, etc.
Definition: CFeature.h:305
#define MRPT_START
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
#define ASSERT_(f)
TInternalFeatList::iterator iterator
Definition: CFeature.h:366



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: ae4571287 Thu Nov 23 00:06:53 2017 +0100 at dom oct 27 23:51:55 CET 2019