-
Notifications
You must be signed in to change notification settings - Fork 0
/
CFramer.cpp
44 lines (37 loc) · 917 Bytes
/
CFramer.cpp
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
// CFramer.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include "opencv2/core/core.hpp"
#include "opencv2/video/tracking.hpp"
#include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/highgui/highgui.hpp"
#include <iostream>
#include <ctype.h>
#include <string>
#include <cstring>
#include <iostream>
using namespace cv;
using namespace std;
void fixFileName(string &fileName){
fileName = fileName.substr(0, fileName.length() - 4);
}
int main(int argc, char* argv[]){
VideoCapture cap;
string fileName(argv[1]);
fixFileName(fileName);
cap.open(argv[1]);
if( !cap.isOpened() )
return 0;
Mat frame;
for(int i = 0; i < 30; i++){
cap >> frame;
if( frame.empty() )
break;
if(i % 7 == 0){
string ruta = fileName + "_frame_" + to_string(i) + ".jpg";
cout << ruta << endl;
imwrite(ruta.c_str(), frame);
}
}
return 0;
}