forked from oreillymedia/Learning-OpenCV-3_examples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
example_02-11.cpp
55 lines (38 loc) · 1.29 KB
/
example_02-11.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#include <opencv2/opencv.hpp>
#include <iostream>
int main( int argc, char* argv[] ) {
cv::namedWindow( "Example 2-11", cv::WINDOW_AUTOSIZE );
cv::namedWindow( "Log_Polar", cv::WINDOW_AUTOSIZE );
// ( Note: could capture from a camera by giving a camera id as an int.)
//
cv::VideoCapture capture( argv[1] );
double fps = capture.get( CV_CAP_PROP_FPS );
cv::Size size(
(int)capture.get( CV_CAP_PROP_FRAME_WIDTH ),
(int)capture.get( CV_CAP_PROP_FRAME_HEIGHT )
);
cv::VideoWriter writer;
writer.open( argv[2], CV_FOURCC('M','J','P','G'), fps, size );
cv::Mat logpolar_frame, bgr_frame;
for(;;) {
capture >> bgr_frame;
if( bgr_frame.empty() ) break; // end if done
cv::imshow( "Example 2-11", bgr_frame );
cv::logPolar(
bgr_frame, // Input color frame
logpolar_frame, // Output log-polar frame
cv::Point2f( // Centerpoint for log-polar transformation
bgr_frame.cols/2, // x
bgr_frame.rows/2 // y
),
40, // Magnitude (scale parameter)
CV_WARP_FILL_OUTLIERS // Fill outliers with 'zero'
);
cv::imshow( "Log_Polar", logpolar_frame );
writer << logpolar_frame;
char c = cv::waitKey(10);
if( c == 27 ) break; // allow the user to break out
}
writer.release();
capture.release();
}