#include <iostream>
int main(
int argc,
char** argv )
{
VideoCapture capture;
Mat log_polar_img, lin_polar_img, recovered_log_polar, recovered_lin_polar_img;
CommandLineParser parser(argc, argv, "{@input|0| camera device number or video file path}");
parser.about("\nThis program illustrates usage of Linear-Polar and Log-Polar image transforms\n");
parser.printMessage();
std::string arg = parser.get<std::string>("@input");
if( arg.size() == 1 && isdigit(arg[0]) )
capture.open( arg[0] - '0' );
else
if( !capture.isOpened() )
{
fprintf(stderr,"Could not initialize capturing...\n");
return -1;
}
Mat src;
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
double M = frame.cols /
log(maxRadius);
logPolar(frame, log_polar_img, center, M, flags);
linearPolar(frame, lin_polar_img, center, maxRadius, flags);
#endif
Mat dst;
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;
{
double Klog = dst.cols /
std::log(maxRadius);
}
else
{
double Klin = dst.cols / maxRadius;
}
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;
}
MatExpr min(const Mat &a, const Mat &b)
void exp(InputArray src, OutputArray dst)
Calculates the exponent of every array element.
void magnitude(InputArray x, InputArray y, OutputArray magnitude)
Calculates the magnitude of 2D vectors.
void log(InputArray src, OutputArray dst)
Calculates the natural logarithm of every array element.
Point2i Point
Definition: modules/core/include/opencv2/core/types.hpp:209
Size2i Size
Definition: modules/core/include/opencv2/core/types.hpp:370
Scalar_< double > Scalar
Definition: modules/core/include/opencv2/core/types.hpp:709
Point_< float > Point2f
Definition: modules/core/include/opencv2/core/types.hpp:207
Quat< T > cos(const Quat< T > &q)
Quat< T > sin(const Quat< T > &q)
cv::String findFileOrKeep(const cv::String &relative_path, bool silentMode=false)
Definition: utility.hpp:1257
int cvRound(double value)
Rounds floating-point number to the nearest integer.
Definition: fast_math.hpp:200
#define CV_2PI
Definition: cvdef.h:381
@ WINDOW_AUTOSIZE
the user cannot resize the window, the size is constrainted by the image displayed.
Definition: highgui.hpp:144
void imshow(const String &winname, InputArray mat)
Displays an image in the specified window.
int waitKey(int delay=0)
Waits for a pressed key.
void namedWindow(const String &winname, int flags=WINDOW_AUTOSIZE)
Creates a window.
void moveWindow(const String &winname, int x, int y)
Moves the window to the specified position.
void drawMarker(InputOutputArray img, Point position, const Scalar &color, int markerType=MARKER_CROSS, int markerSize=20, int thickness=1, int line_type=8)
Draws a marker on a predefined position in an image.
int main(int argc, char *argv[])
Definition: highgui_qt.cpp:3
Definition: core/include/opencv2/core.hpp:107