-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvideoTest2.cpp
More file actions
48 lines (44 loc) · 1.07 KB
/
videoTest2.cpp
File metadata and controls
48 lines (44 loc) · 1.07 KB
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
//#include "opencv2\opencv.hpp"
#include <opencv2/opencv.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <iostream>
#include <string>
#include <time.h>
#define VIDEO_PORT 1
using namespace cv;
using namespace std;
void recordTime() {
static int i = 0;
static clock_t startTime, endTime;
if (i==0) {
startTime = clock();
i = 1;
}
else {
endTime = clock();
i = 0;
cout << "Totle Time : " <<(double)(endTime - startTime) / CLOCKS_PER_SEC << "s" << endl;
}
}
int main(int argc, char** argv)
{
VideoCapture capture(VIDEO_PORT);
Mat frame;
if(!capture.isOpened())
{
cout<<"摄像头打开失败!"<<endl;
return -1;
}
int i = 0;
recordTime();
while(i < 500)
{
capture >> frame;
cout << "video" << VIDEO_PORT << " get frame " << i << endl;
imwrite("imgs/v" + to_string(VIDEO_PORT) + "_frame_" + to_string(i) + ".jpg", frame);//图片保存到本工程目录中
i++;
}
recordTime();
return 0;
}