#include <iostream>
static void help( void )
{
printf("\nThis program illustrates Linear-Polar and Log-Polar image transforms\n"
"Usage :\n"
"./polar_transforms [[camera number -- Default 0],[path_to_filename]]\n\n");
}
int main( int argc, char** argv )
{
Mat log_polar_img, lin_polar_img, recovered_log_polar, recovered_lin_polar_img;
help();
std::string arg = parser.
get<std::string>(
"@input");
if( arg.size() == 1 && isdigit(arg[0]) )
capture.
open( arg[0] -
'0' );
else
{
const char* name = argv[0];
fprintf(stderr,"Could not initialize capturing...\n");
fprintf(stderr,"Usage: %s <CAMERA_NUMBER> , or \n %s <VIDEO_FILE>\n", name, name);
return -1;
}
for(;;)
{
capture >> src;
if(src.empty() )
break;
Point2f center( (
float)src.cols / 2, (
float)src.rows / 2 );
double maxRadius = 0.7*
min(center.
y, center.
x);
#if 0 //deprecated
double M = frame.cols /
log(maxRadius);
logPolar(frame, log_polar_img, center, M, flags);
linearPolar(frame, lin_polar_img, center, maxRadius, flags);
#endif
dst = log_polar_img;
else
dst = lin_polar_img;
int rho =
cvRound(dst.cols * 0.75);
double Kangle = dst.rows /
CV_2PI;
angleRad = phi / Kangle;
if (flags & WARP_POLAR_LOG)
{
double Klog = dst.cols /
std::log(maxRadius);
}
else
{
double Klin = dst.cols / maxRadius;
magnitude = rho / Klin;
}
#if 0 //C version
CvMat dst = lin_polar_img;
CvMat inverse = recovered_lin_polar_img;
#endif
imshow(
"Log-Polar", log_polar_img);
imshow(
"Linear-Polar", lin_polar_img);
imshow(
"Recovered Linear-Polar", recovered_lin_polar_img );
imshow(
"Recovered Log-Polar", recovered_log_polar );
break;
}
return 0;
}