코드 4-3 동영상 파일 처리 예제 프로그램 [ch04/video]
01 void video_in() 02 { 03 VideoCapture cap("stopwatch.avi"); 04 05 if (!cap.isOpened()) { 06 cerr << "Video open failed!" << endl; 07 return; 08 } 09 10 cout << "Frame width: " << cvRound(cap.get(CAP_PROP_FRAME_WIDTH)) << endl; 11 cout << "Frame height: " << cvRound(cap.get(CAP_PROP_FRAME_HEIGHT)) << endl; 12 cout << "Frame count: " << cvRound(cap.get(CAP_PROP_FRAME_COUNT)) << endl; 13 14 double fps = cap.get(CAP_PROP_FPS); 15 cout << "FPS: " << fps << endl; 16 17 int delay = cvRound(1000 / fps); 18 19 Mat frame, inversed; 20 while (true) { 21 cap >> frame; 22 if (frame.empty()) 23 break; 24 25 inversed = ~frame; 26 27 imshow("frame", frame); 28 imshow("inversed", inversed); 29 30 if (waitKey(delay) = = 27) // ESC key 31 break; 32 } 33 34 destroyAllWindows(); 35 }