15 #include <mrpt/otherlibs/do_opencv_includes.h> 27 #if MRPT_HAS_OPENCV && MRPT_OPENCV_VERSION_NUM < 0x111 29 CvPoint2D32f center,
double maxRadius,
int flags )
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 ))
47 CV_ERROR( CV_StsUnmatchedFormats,
"" );
49 ssize.width =
src->cols;
50 ssize.height =
src->rows;
51 dsize.width =
dst->cols;
52 dsize.height =
dst->rows;
54 CV_CALL( mapx = cvCreateMat( dsize.height, dsize.width, CV_32F ));
55 CV_CALL( mapy = cvCreateMat( dsize.height, dsize.width, CV_32F ));
57 if( !(flags & CV_WARP_INVERSE_MAP) )
61 for( phi = 0; phi < dsize.height; phi++ )
63 double cp = cos(phi*2*
CV_PI/(dsize.height-1));
64 double sp = sin(phi*2*
CV_PI/(dsize.height-1));
65 float* mx = (
float*)(mapx->data.ptr + phi*mapx->step);
66 float* my = (
float*)(mapy->data.ptr + phi*mapy->step);
68 for( rho = 0; rho < dsize.width; rho++ )
70 double r = maxRadius*(rho+1)/
double(dsize.width-1);
71 double x =
r*cp + center.x;
72 double y =
r*sp + center.y;
82 CvMat bufx, bufy, bufp, bufa;
83 const double ascale = (ssize.height-1)/(2*
CV_PI);
84 const double pscale = (ssize.width-1)/maxRadius;
86 CV_CALL( buf = (
float*)cvAlloc( 4*dsize.width*
sizeof(buf[0]) ));
88 bufx = cvMat( 1, dsize.width, CV_32F, buf );
89 bufy = cvMat( 1, dsize.width, CV_32F, buf + dsize.width );
90 bufp = cvMat( 1, dsize.width, CV_32F, buf + dsize.width*2 );
91 bufa = cvMat( 1, dsize.width, CV_32F, buf + dsize.width*3 );
93 for(
x = 0;
x < dsize.width;
x++ )
94 bufx.data.fl[
x] = (
float)
x - center.x;
96 for(
y = 0;
y < dsize.height;
y++ )
98 float* mx = (
float*)(mapx->data.ptr +
y*mapx->step);
99 float* my = (
float*)(mapy->data.ptr +
y*mapy->step);
101 for(
x = 0;
x < dsize.width;
x++ )
102 bufy.data.fl[
x] = (
float)
y - center.y;
104 cvCartToPolar( &bufx, &bufy, &bufp, &bufa, 0 );
106 for(
x = 0;
x < dsize.width;
x++ )
107 bufp.data.fl[
x] += 1.f;
109 for(
x = 0;
x < dsize.width;
x++ )
111 double rho = bufp.data.fl[
x]*pscale;
112 double phi = bufa.data.fl[
x]*ascale;
119 cvRemap(
src,
dst, mapx, mapy, flags, cvScalarAll(0) );
124 cvReleaseMat( &mapx );
125 cvReleaseMat( &mapy );
140 ASSERT_(options.PolarImagesOptions.radius>1)
141 ASSERT_(options.PolarImagesOptions.bins_angle>1)
142 ASSERT_(options.PolarImagesOptions.bins_distance>1)
144 const unsigned int radius = options.PolarImagesOptions.radius;
145 const unsigned int patch_w = options.PolarImagesOptions.bins_distance;
146 const unsigned int patch_h = options.PolarImagesOptions.bins_angle;
154 (*it)->scale = radius;
157 #if MRPT_OPENCV_VERSION_NUM < 0x111 162 in_img.
getAs<IplImage>(),
163 linpolar_frame.getAs<IplImage>(),
164 cvPoint2D32f( (*it)->x,(*it)->y ),
166 CV_INTER_LINEAR+CV_WARP_FILL_OUTLIERS );
169 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)
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