 |
OpenCV
3.2.0
Open Source Computer Vision
|
An example using the cv::linearPolar and cv::logPolar operations
#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
capture.
open( arg.c_str() );
{
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 >> frame;
if( frame.empty() )
break;
Point2f center( (
float)frame.cols / 2, (
float)frame.rows / 2 );
double radius = (double)frame.cols / 4;
double M = (
double)frame.cols /
log(radius);
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;
}
void moveWindow(const String &winname, int x, int y)
Moves window to the specified position.
Class for video capturing from video files, image sequences or cameras.
Definition: videoio.hpp:597
int waitKey(int delay=0)
Waits for a pressed key.
void namedWindow(const String &winname, int flags=WINDOW_AUTOSIZE)
Creates a window.
virtual bool isOpened() const
Returns true if video capturing has been initialized already.
virtual bool open(const String &filename)
Open video file or a capturing device or a IP video stream for video capturing.
void imshow(const String &winname, InputArray mat)
Displays an image in the specified window.
n-dimensional dense array class
Definition: mat.hpp:741
Designed for command line parsing.
Definition: utility.hpp:735
Definition: affine.hpp:52
@ WINDOW_AUTOSIZE
the user cannot resize the window, the size is constrainted by the image displayed.
Definition: highgui.hpp:184
fprintf(outfile, '%%YAML:1.0\n\n')
void log(InputArray src, OutputArray dst)
Calculates the natural logarithm of every array element.