How to extract video from a video file 영상 추출 하기
OpenCV 2019. 6. 29. 17:56 |반응형
Explains how to extract video from a video file using OpenCV VideoWriter.
OpenCV의 VideoWriter를 이용해 비디오 파일의 영상 부분만 추출 한다.
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 | #include <opencv2/opencv.hpp> using namespace std; using namespace cv; int main() { VideoCapture capture("Earth.mp4"); CV_Assert(capture.isOpened()); int fourcc = VideoWriter::fourcc('m', 'p', '4', 'v'); double fps = capture.get(CAP_PROP_FPS); Size size((int)capture.get(CAP_PROP_FRAME_WIDTH), (int)capture.get(CAP_PROP_FRAME_HEIGHT)); int delay = cvRound(1000.0 / fps); cout << "FPS: " << fps << endl << "Size: " << size << endl << "Number of frames: " << capture.get(CAP_PROP_FRAME_COUNT) << endl; VideoWriter writer; writer.open("copy.mp4", fourcc, fps, size); CV_Assert(writer.isOpened()); while (true) { Mat frame; capture >> frame; if (frame.empty()) break; writer << frame; imshow("Earth", frame); if (waitKey(delay) >= 0) break; } return 0; } |
반응형
'OpenCV' 카테고리의 다른 글
OpenCV VideoCapture class for playing image sequence like a video file (0) | 2019.07.02 |
---|---|
OpenCV Graphic User Interface(GUI) with cvui (1) | 2019.07.01 |
Video Analysis - Optical Flow (0) | 2019.01.03 |
tkinter GUI (0) | 2018.12.29 |
Video Analysis - Meanshift and CAMshift (0) | 2018.12.27 |