forked from amanwalia123/Opencv-ARM64
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathopencv-vid-test.cpp
More file actions
51 lines (35 loc) · 991 Bytes
/
opencv-vid-test.cpp
File metadata and controls
51 lines (35 loc) · 991 Bytes
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
#include "opencv2/opencv.hpp"
#include <iostream>
#include <string>
#define FRAME "frame_"
#define EXT ".png"
int main(){
std::cout<<"Hello"<<std::endl;
// Create a VideoCapture object and open the input file
// If the input is the web camera, pass 0 instead of the video file name
cv::VideoCapture cap("test.mp4");
// Check if camera opened successfully
if(!cap.isOpened()){
std::cout << "Error opening video stream or file" <<std::endl;
return -1;
}
int i = 1;
while(1){
cv::Mat frame;
// Capture frame-by-frame
cap >> frame;
// If the frame is empty, break immediately
if (frame.empty())
break;
// Display the resulting frame
cv::imshow( "Frame", frame );
if(i %300 == 0){
std::cout<<"Read frame"<<i<<std::endl;
cv::imwrite(FRAME+std::to_string(i)+EXT,frame);
}
i++;
}
// When everything done, release the video capture object
cap.release();
return 0;
}