결과값
코드
#include "opencv2/opencv.hpp"
#include <iostream>
using namespace cv;
using namespace std;
int main(){
VideoCapture capture("image/Wildlife.wmv");
int fps = capture.get(CAP_PROP_FPS);
int ex = static_cast<int>(capture.get(CV_CAP_PROP_FOURCC));
char EXT[] = {
(char)(ex & 0XFF),
(char)((ex & 0XFF00) >> 8),
(char)((ex & 0XFF0000) >> 16),
(char)((ex & 0XFF000000) >> 24),
0
};
int hei = capture.get(CAP_PROP_FRAME_HEIGHT);
int wid = capture.get(CAP_PROP_FRAME_WIDTH);
printf("fourcc = %s \n", EXT);
printf("size = [%d x %d]\n", wid, hei);
printf("fps = %d\n", fps);
Mat frame;
Mat frameCanny;
//namedWindow("input", 1);
Size size = Size((int)capture.get(CAP_PROP_FRAME_WIDTH),
(int)capture.get(CAP_PROP_FRAME_HEIGHT));
VideoWriter outputVideo;
outputVideo.open("ouput.avi", CV_FOURCC('D', 'I', 'B', ' '), fps, size, true);
if (!outputVideo.isOpened())
{
cout << "동영상을 저장하기 위한 초기화 작업 중 에러 발생" << endl;
return 1;
}
while (1)
{
capture >> frame;
if (!frame.empty()) {
Canny(frame, frameCanny, 80, 150, 3);
imshow("video", frame);
imshow("Canny", frameCanny);
outputVideo << frameCanny;
outputVideo.write(frameCanny);
if (waitKey(30) == 'q') break;
}
}
return 0;
}
'Programming > openCV' 카테고리의 다른 글
10. 마우스로 영역을 지정한 부분만 엣지 검출 (0) | 2017.04.04 |
---|---|
9. sobel Filter / Canny Edge (0) | 2017.04.04 |
7. 비디오 출력하기 (0) | 2017.04.04 |
6. 디졸브와 트랙바 (0) | 2017.04.04 |
5. 영상 디졸브 (0) | 2017.04.04 |