Main MRPT website > C++ reference for MRPT 1.5.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 
18 using namespace mrpt;
19 using namespace mrpt::vision;
20 using namespace mrpt::system;
21 using namespace std;
22 
23 
24 /************************************************************************************************
25  computeLogPolarImageDescriptors
26 ************************************************************************************************/
28  const mrpt::utils::CImage &in_img,
29  CFeatureList &in_features) const
30 {
32 #if MRPT_HAS_OPENCV
33 
34  ASSERT_(options.LogPolarImagesOptions.radius>1)
35  ASSERT_(options.LogPolarImagesOptions.num_angles>1)
36  ASSERT_(options.LogPolarImagesOptions.rho_scale>0)
37 
38  const unsigned int radius = options.LogPolarImagesOptions.radius;
39  const unsigned int patch_h = options.LogPolarImagesOptions.num_angles;
40  const double rho_scale = options.LogPolarImagesOptions.rho_scale;
41  const unsigned int patch_w = rho_scale * std::log(static_cast<double>(radius));
42 
43  mrpt::utils::CImage logpolar_frame( patch_w, patch_h, in_img.getChannelCount() );
44 
45  // Compute intensity-domain spin images
46  for (CFeatureList::iterator it=in_features.begin();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>(),
54  logpolar_frame.getAs<IplImage>(),
55  cvPoint2D32f( (*it)->x,(*it)->y ),
56  rho_scale,
57  CV_INTER_LINEAR+CV_WARP_FILL_OUTLIERS );
58 
59  // Get the image as a matrix and save as patch:
60  logpolar_frame.getAsMatrix( (*it)->descriptors.LogPolarImg );
61 
62  } // end for it
63 
64 
65 #else
66  THROW_EXCEPTION("This method needs MRPT compiled with OpenCV support")
67 #endif
68  MRPT_END
69 }
70 
TImageChannels getChannelCount() const
Returns the number of channels, typically 1 (GRAY) or 3 (RGB)
Definition: CImage.cpp:912
This namespace provides a OS-independent interface to many useful functions: filenames manipulation...
Definition: math_frwds.h:29
A class for storing images as grayscale or RGB bitmaps.
Definition: CImage.h:101
#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:517
#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:211
#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:261



Page generated by Doxygen 1.8.14 for MRPT 1.5.9 Git: 690a4699f Wed Apr 15 19:29:53 2020 +0200 at miƩ abr 15 19:30:12 CEST 2020