1 #include "opencv2/imgproc/imgproc.hpp"
2 #include "opencv2/highgui/highgui.hpp"
4 #include "opencv2/imgproc/imgproc_c.h"
11 printf("\nThis program illustrates Linear-Polar and Log-Polar image transforms\n"
13 "./polar_transforms [[camera number -- Default 0],[AVI path_filename]]\n\n"
16 int main( int argc, char** argv )
18 CvCapture* capture = 0;
19 IplImage* log_polar_img = 0;
20 IplImage* lin_polar_img = 0;
21 IplImage* recovered_img = 0;
25 if( argc == 1 || (argc == 2 && strlen(argv[1]) == 1 && isdigit(argv[1][0])))
26 capture = cvCaptureFromCAM( argc == 2 ? argv[1][0] - '0' : 0 );
28 capture = cvCaptureFromAVI( argv[1] );
31 fprintf(stderr,"Could not initialize capturing...\n");
32 fprintf(stderr,"Usage: %s <CAMERA_NUMBER> , or \n %s <VIDEO_FILE>\n",argv[0],argv[0]);
37 cvNamedWindow( "Linear-Polar", 0 );
38 cvNamedWindow( "Log-Polar", 0 );
39 cvNamedWindow( "Recovered image", 0 );
41 cvMoveWindow( "Linear-Polar", 20,20 );
42 cvMoveWindow( "Log-Polar", 700,20 );
43 cvMoveWindow( "Recovered image", 20,700 );
49 frame = cvQueryFrame( capture );
55 log_polar_img = cvCreateImage( cvSize(frame->width,frame->height), IPL_DEPTH_8U, frame->nChannels );
56 lin_polar_img = cvCreateImage( cvSize(frame->width,frame->height), IPL_DEPTH_8U, frame->nChannels );
57 recovered_img = cvCreateImage( cvSize(frame->width,frame->height), IPL_DEPTH_8U, frame->nChannels );
60 cvLogPolar(frame,log_polar_img,cvPoint2D32f(frame->width >> 1,frame->height >> 1),70, CV_INTER_LINEAR+CV_WARP_FILL_OUTLIERS);
61 cvLinearPolar(frame,lin_polar_img,cvPoint2D32f(frame->width >> 1,frame->height >> 1),70, CV_INTER_LINEAR+CV_WARP_FILL_OUTLIERS);
64 cvLogPolar(log_polar_img,recovered_img,cvPoint2D32f(frame->width >> 1,frame->height >> 1),70, CV_WARP_INVERSE_MAP+CV_INTER_LINEAR);
66 cvLinearPolar(lin_polar_img,recovered_img,cvPoint2D32f(frame->width >> 1,frame->height >> 1),70, CV_WARP_INVERSE_MAP+CV_INTER_LINEAR+CV_WARP_FILL_OUTLIERS);
69 cvShowImage("Log-Polar", log_polar_img );
70 cvShowImage("Linear-Polar", lin_polar_img );
71 cvShowImage("Recovered image", recovered_img );
73 if( cvWaitKey(10) >= 0 )
77 cvReleaseCapture( &capture );
78 cvDestroyWindow("Linear-Polar");
79 cvDestroyWindow("Log-Polar");
80 cvDestroyWindow("Recovered image");