1 #include "opencv2/imgproc/imgproc_c.h"
2 #include "opencv2/highgui/highgui_c.h"
7 static void help( void )
9 printf("\nThis program illustrates Linear-Polar and Log-Polar image transforms\n"
11 "./polar_transforms [[camera number -- Default 0],[AVI path_filename]]\n\n"
14 int main( int argc, char** argv )
16 CvCapture* capture = 0;
17 IplImage* log_polar_img = 0;
18 IplImage* lin_polar_img = 0;
19 IplImage* recovered_img = 0;
23 if( argc == 1 || (argc == 2 && strlen(argv[1]) == 1 && isdigit(argv[1][0])))
24 capture = cvCaptureFromCAM( argc == 2 ? argv[1][0] - '0' : 0 );
26 capture = cvCaptureFromAVI( argv[1] );
29 fprintf(stderr,"Could not initialize capturing...\n");
30 fprintf(stderr,"Usage: %s <CAMERA_NUMBER> , or \n %s <VIDEO_FILE>\n",argv[0],argv[0]);
35 cvNamedWindow( "Linear-Polar", 0 );
36 cvNamedWindow( "Log-Polar", 0 );
37 cvNamedWindow( "Recovered image", 0 );
39 cvMoveWindow( "Linear-Polar", 20,20 );
40 cvMoveWindow( "Log-Polar", 700,20 );
41 cvMoveWindow( "Recovered image", 20,700 );
47 frame = cvQueryFrame( capture );
53 log_polar_img = cvCreateImage( cvSize(frame->width,frame->height), IPL_DEPTH_8U, frame->nChannels );
54 lin_polar_img = cvCreateImage( cvSize(frame->width,frame->height), IPL_DEPTH_8U, frame->nChannels );
55 recovered_img = cvCreateImage( cvSize(frame->width,frame->height), IPL_DEPTH_8U, frame->nChannels );
58 cvLogPolar(frame,log_polar_img,cvPoint2D32f(frame->width >> 1,frame->height >> 1),70, CV_INTER_LINEAR+CV_WARP_FILL_OUTLIERS);
59 cvLinearPolar(frame,lin_polar_img,cvPoint2D32f(frame->width >> 1,frame->height >> 1),70, CV_INTER_LINEAR+CV_WARP_FILL_OUTLIERS);
62 cvLogPolar(log_polar_img,recovered_img,cvPoint2D32f(frame->width >> 1,frame->height >> 1),70, CV_WARP_INVERSE_MAP+CV_INTER_LINEAR);
64 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);
67 cvShowImage("Log-Polar", log_polar_img );
68 cvShowImage("Linear-Polar", lin_polar_img );
69 cvShowImage("Recovered image", recovered_img );
71 if( cvWaitKey(10) >= 0 )
75 cvReleaseCapture( &capture );
76 cvDestroyWindow("Linear-Polar");
77 cvDestroyWindow("Log-Polar");
78 cvDestroyWindow("Recovered image");