-
Notifications
You must be signed in to change notification settings - Fork 37
/
1351-2
56 lines (39 loc) · 894 Bytes
/
1351-2
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
56
#include <opencv2/core.hpp>
#include <opencv2/videoio.hpp>
#include <opencv2/highgui.hpp>
//#include <opencv2/imgproc.hpp> // for cvtColor
#include <iostream>
using namespace cv;
using namespace std;
int main()
{
Mat frame;
VideoCapture cap(0);
if (!cap.isOpened())
{
cerr << "카메라를 열 수 없습니다." << endl;
return -1;
}
int fps = 30;
int width = cap.get(CAP_PROP_FRAME_WIDTH);
int height = cap.get(CAP_PROP_FRAME_HEIGHT);
int fourcc = VideoWriter::fourcc('M','J','P','G');
VideoWriter outputVideo;
outputVideo.open("output.avi", fourcc, fps, Size(width, height), true);
while(1)
{
cap.read(frame);
if (frame.empty())
{
cerr << "캡쳐 실패" << endl;
break;
}
//cvtColor(frame, frame, COLOR_BGR2GRAY);
imshow("Live", frame);
outputVideo.write(frame);
if (waitKey(1) >= 0)
break;
}
outputVideo.release();
return 0;
}