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-2018, 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::img;
20 using namespace mrpt::system;
21 using namespace std;
22 
23 /************************************************************************************************
24  computeLogPolarImageDescriptors
25 ************************************************************************************************/
27  const mrpt::img::CImage& in_img, CFeatureList& in_features) const
28 {
30 #if MRPT_HAS_OPENCV
31 
32  ASSERT_(options.LogPolarImagesOptions.radius > 1);
33  ASSERT_(options.LogPolarImagesOptions.num_angles > 1);
34  ASSERT_(options.LogPolarImagesOptions.rho_scale > 0);
35 
36  const unsigned int radius = options.LogPolarImagesOptions.radius;
37  const unsigned int patch_h = options.LogPolarImagesOptions.num_angles;
38  const double rho_scale = options.LogPolarImagesOptions.rho_scale;
39  const unsigned int patch_w =
40  rho_scale * std::log(static_cast<double>(radius));
41 
42  mrpt::img::CImage logpolar_frame(
43  patch_w, patch_h, in_img.getChannelCount());
44 
45  // Compute intensity-domain spin images
46  for (CFeatureList::iterator it = in_features.begin();
47  it != in_features.end(); ++it)
48  {
49  // Overwrite scale with the descriptor scale:
50  (*it)->scale = radius;
51 
52  // Use OpenCV to convert:
53  cvLogPolar(
54  in_img.getAs<IplImage>(), logpolar_frame.getAs<IplImage>(),
55  cvPoint2D32f((*it)->x, (*it)->y), rho_scale,
56  CV_INTER_LINEAR + CV_WARP_FILL_OUTLIERS);
57 
58  // Get the image as a matrix and save as patch:
59  logpolar_frame.getAsMatrix((*it)->descriptors.LogPolarImg);
60 
61  } // end for it
62 
63 #else
64  THROW_EXCEPTION("This method needs MRPT compiled with OpenCV support");
65 #endif
66  MRPT_END
67 }
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: img/CImage.h:599
#define MRPT_START
Definition: exceptions.h:262
TInternalFeatList::iterator iterator
Definition: CFeature.h:365
This namespace provides a OS-independent interface to many useful functions: filenames manipulation...
Definition: math_frwds.h:25
#define THROW_EXCEPTION(msg)
Definition: exceptions.h:41
TImageChannels getChannelCount() const
Returns the number of channels, typically 1 (GRAY) or 3 (RGB)
Definition: CImage.cpp:920
STL namespace.
#define ASSERT_(f)
Defines an assertion mechanism.
Definition: exceptions.h:113
Classes for computer vision, detectors, features, etc.
Definition: CCamModel.h:20
A list of visual features, to be used as output by detectors, as input/output by trackers, etc.
Definition: CFeature.h:304
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
#define MRPT_END
Definition: exceptions.h:266
void internal_computeLogPolarImageDescriptors(const mrpt::img::CImage &in_img, CFeatureList &in_features) const
Compute a log-polar image descriptor of the provided features into the input image.
A class for storing images as grayscale or RGB bitmaps.
Definition: img/CImage.h:130



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: ad3a9d8ae Tue May 1 23:10:22 2018 -0700 at lun oct 28 00:14:14 CET 2019