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 }
mrpt::img::CImage::getChannelCount
TImageChannels getChannelCount() const
Returns the number of channels, typically 1 (GRAY) or 3 (RGB)
Definition: CImage.cpp:920
mrpt::img::CImage::getAsMatrix
void getAsMatrix(mrpt::math::CMatrixFloat &outMatrix, bool doResize=true, int x_min=0, int y_min=0, int x_max=-1, int y_max=-1) const
Returns the image as a matrix with pixel grayscale values in the range [0,1].
Definition: CImage.cpp:1616
mrpt::vision
Classes for computer vision, detectors, features, etc.
Definition: CCamModel.h:20
mrpt::vision::CFeatureList::iterator
TInternalFeatList::iterator iterator
Definition: CFeature.h:367
mrpt
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
Definition: CKalmanFilterCapable.h:30
mrpt::img::CImage::getAs
const T * getAs() const
Returns a pointer to a const T* containing the image - the idea is to call like "img....
Definition: img/CImage.h:599
mrpt::vision::CFeatureList::begin
iterator begin()
Definition: CFeature.h:373
THROW_EXCEPTION
#define THROW_EXCEPTION(msg)
Definition: exceptions.h:41
ASSERT_
#define ASSERT_(f)
Defines an assertion mechanism.
Definition: exceptions.h:113
vision-precomp.h
mrpt::vision::CFeatureList
A list of visual features, to be used as output by detectors, as input/output by trackers,...
Definition: CFeature.h:304
mrpt::img
Definition: CCanvas.h:17
MRPT_START
#define MRPT_START
Definition: exceptions.h:262
mrpt::vision::CFeatureExtraction::internal_computeLogPolarImageDescriptors
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.
Definition: CFeatureExtraction_logPolarImg.cpp:26
CFeatureExtraction.h
mrpt::img::CImage
A class for storing images as grayscale or RGB bitmaps.
Definition: img/CImage.h:130
mrpt::vision::CFeatureList::end
iterator end()
Definition: CFeature.h:374
MRPT_END
#define MRPT_END
Definition: exceptions.h:266
mrpt::system
This namespace provides a OS-independent interface to many useful functions: filenames manipulation,...
Definition: math_frwds.h:25



Page generated by Doxygen 1.8.17 for MRPT 1.9.9 Git: ad3a9d8ae Tue May 1 23:10:22 2018 -0700 at miƩ 12 jul 2023 10:03:34 CEST