15 #include <mrpt/otherlibs/do_opencv_includes.h> 26 #if MRPT_HAS_OPENCV && MRPT_OPENCV_VERSION_NUM < 0x111 28 const CvArr* srcarr, CvArr* dstarr, CvPoint2D32f center,
double maxRadius,
35 CV_FUNCNAME(
"cvLinPolar");
39 CvMat srcstub, *
src = (CvMat *)srcarr;
40 CvMat dststub, *
dst = (CvMat *)dstarr;
43 CV_CALL(
src = cvGetMat(srcarr, &srcstub, 0, 0));
44 CV_CALL(
dst = cvGetMat(dstarr, &dststub, 0, 0));
46 if (!CV_ARE_TYPES_EQ(
src,
dst)) CV_ERROR(CV_StsUnmatchedFormats,
"");
48 ssize.width =
src->cols;
49 ssize.height =
src->rows;
50 dsize.width =
dst->cols;
51 dsize.height =
dst->rows;
53 CV_CALL(mapx = cvCreateMat(dsize.height, dsize.width, CV_32F));
54 CV_CALL(mapy = cvCreateMat(dsize.height, dsize.width, CV_32F));
56 if (!(flags & CV_WARP_INVERSE_MAP))
60 for (phi = 0; phi < dsize.height; phi++)
62 double cp = cos(phi * 2 *
CV_PI / (dsize.height - 1));
63 double sp = sin(phi * 2 *
CV_PI / (dsize.height - 1));
64 float* mx = (
float*)(mapx->data.ptr + phi * mapx->step);
65 float* my = (
float*)(mapy->data.ptr + phi * mapy->step);
67 for (rho = 0; rho < dsize.width; rho++)
69 double r = maxRadius * (rho + 1) /
double(dsize.width - 1);
70 double x =
r * cp + center.x;
71 double y =
r * sp + center.y;
81 CvMat bufx, bufy, bufp, bufa;
82 const double ascale = (ssize.height - 1) / (2 *
CV_PI);
83 const double pscale = (ssize.width - 1) / maxRadius;
85 CV_CALL(buf = (
float*)cvAlloc(4 * dsize.width *
sizeof(buf[0])));
87 bufx = cvMat(1, dsize.width, CV_32F, buf);
88 bufy = cvMat(1, dsize.width, CV_32F, buf + dsize.width);
89 bufp = cvMat(1, dsize.width, CV_32F, buf + dsize.width * 2);
90 bufa = cvMat(1, dsize.width, CV_32F, buf + dsize.width * 3);
92 for (
x = 0;
x < dsize.width;
x++) bufx.data.fl[
x] = (
float)
x - center.x;
94 for (
y = 0;
y < dsize.height;
y++)
96 float* mx = (
float*)(mapx->data.ptr +
y * mapx->step);
97 float* my = (
float*)(mapy->data.ptr +
y * mapy->step);
99 for (
x = 0;
x < dsize.width;
x++)
100 bufy.data.fl[
x] = (
float)
y - center.y;
102 cvCartToPolar(&bufx, &bufy, &bufp, &bufa, 0);
104 for (
x = 0;
x < dsize.width;
x++) bufp.data.fl[
x] += 1.f;
106 for (
x = 0;
x < dsize.width;
x++)
108 double rho = bufp.data.fl[
x] * pscale;
109 double phi = bufa.data.fl[
x] * ascale;
116 cvRemap(
src,
dst, mapx, mapy, flags, cvScalarAll(0));
135 ASSERT_(options.PolarImagesOptions.radius > 1)
136 ASSERT_(options.PolarImagesOptions.bins_angle > 1)
137 ASSERT_(options.PolarImagesOptions.bins_distance > 1)
139 const unsigned int radius = options.PolarImagesOptions.radius;
140 const unsigned int patch_w = options.PolarImagesOptions.bins_distance;
141 const unsigned int patch_h = options.PolarImagesOptions.bins_angle;
147 it != in_features.
end(); ++it)
150 (*it)->scale = radius;
153 #if MRPT_OPENCV_VERSION_NUM < 0x111 158 in_img.
getAs<IplImage>(),
159 linpolar_frame.getAs<IplImage>(),
160 cvPoint2D32f( (*it)->x,(*it)->y ),
162 CV_INTER_LINEAR+CV_WARP_FILL_OUTLIERS );
165 linpolar_frame.getAsMatrix((*it)->descriptors.PolarImg);
TImageChannels getChannelCount() const
Returns the number of channels, typically 1 (GRAY) or 3 (RGB)
This namespace provides a OS-independent interface to many useful functions: filenames manipulation...
A class for storing images as grayscale or RGB bitmaps.
#define THROW_EXCEPTION(msg)
for(ctr=DCTSIZE;ctr > 0;ctr--)
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's headers.
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.
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
GLdouble GLdouble GLdouble r
TInternalFeatList::iterator iterator