MRPT  1.9.9
CFeatureExtraction_polarImg.cpp
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | https://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2019, Individual contributors, see AUTHORS file |
6  | See: https://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See: https://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 // Linear-Polar Transform
24 // J.L. Blanco, Apr 2009
25 // Code contributed to OpenCV 1.1.1 long time ago. Removed from MRPT now.
26 
28  const mrpt::img::CImage& in_img, CFeatureList& in_features)
29 {
31 #if MRPT_HAS_OPENCV
32 
34  profiler, "internal_computePolarImageDescriptors");
35 
36  ASSERT_(options.PolarImagesOptions.radius > 1);
37  ASSERT_(options.PolarImagesOptions.bins_angle > 1);
38  ASSERT_(options.PolarImagesOptions.bins_distance > 1);
39 
40  const unsigned int radius = options.PolarImagesOptions.radius;
41  const unsigned int patch_w = options.PolarImagesOptions.bins_distance;
42  const unsigned int patch_h = options.PolarImagesOptions.bins_angle;
43 
44  CImage linpolar_frame(patch_w, patch_h, in_img.getChannelCount());
45 
46  // Compute intensity-domain spin images
47  for (auto& f : in_features)
48  {
49  // Overwrite scale with the descriptor scale:
50  f.keypoint.octave = radius;
51 
52  const auto pt = cv::Point2f(f.keypoint.pt.x, f.keypoint.pt.y);
53 
54  const cv::Mat& in = in_img.asCvMatRef();
55  cv::Mat& out = linpolar_frame.asCvMatRef();
56 
57 #if MRPT_OPENCV_VERSION_NUM < 0x300
58  IplImage cvin, cvout;
59  in_img.getAsIplImage(&cvin);
60  linpolar_frame.getAsIplImage(&cvout);
61  cvLinearPolar(
62  &cvin, &cvout, pt, radius, CV_INTER_LINEAR + CV_WARP_FILL_OUTLIERS);
63 #elif MRPT_OPENCV_VERSION_NUM < 0x342
64  cv::linearPolar(
65  in(cv::Rect(
66  pt.x - radius, pt.y - radius, 1 + 2 * radius, 1 + 2 * radius)),
67  out, pt, radius, CV_INTER_LINEAR + CV_WARP_FILL_OUTLIERS);
68 #else
69  // Latest opencv versions:
70  cv::warpPolar(
71  in, out, cv::Size(patch_w, patch_h), pt, radius,
72  cv::INTER_LINEAR + cv::WARP_FILL_OUTLIERS);
73 #endif
74 
75  // Get the image as a matrix and save as patch:
76  f.descriptors.PolarImg.emplace();
77  linpolar_frame.getAsMatrix(*f.descriptors.PolarImg);
78 
79  } // end for it
80 
81 #else
82  THROW_EXCEPTION("This method needs MRPT compiled with OpenCV support");
83 #endif
84  MRPT_END
85 }
#define MRPT_START
Definition: exceptions.h:241
#define THROW_EXCEPTION(msg)
Definition: exceptions.h:67
A safe way to call enter() and leave() of a mrpt::system::CTimeLogger upon construction and destructi...
cv::Mat & asCvMatRef()
Get a reference to the internal cv::Mat, which can be resized, etc.
Definition: CImage.cpp:234
TImageChannels getChannelCount() const
Returns the number of channels, typically 1 (GRAY) or 3 (RGB)
Definition: CImage.cpp:907
STL namespace.
#define ASSERT_(f)
Defines an assertion mechanism.
Definition: exceptions.h:120
Classes for computer vision, detectors, features, etc.
Definition: CDifodo.h:17
void getAsIplImage(IplImage *dest) const
(DEPRECATED, DO NOT USE - Kept here only to interface opencv 2.4)
Definition: CImage.cpp:2133
A list of visual features, to be used as output by detectors, as input/output by trackers, etc.
Definition: CFeature.h:275
void internal_computePolarImageDescriptors(const mrpt::img::CImage &in_img, CFeatureList &in_features)
Compute a polar-image descriptor of the provided features into the input image.
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
mrpt::vision::TStereoCalibResults out
struct _IplImage IplImage
Definition: img/CImage.h:21
#define MRPT_END
Definition: exceptions.h:245
GLuint in
Definition: glext.h:7391
A class for storing images as grayscale or RGB bitmaps.
Definition: img/CImage.h:147



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: c1796881b Sat Nov 16 19:04:34 2019 +0100 at sáb nov 16 19:15:10 CET 2019