-
Notifications
You must be signed in to change notification settings - Fork 3
/
process.cpp
69 lines (49 loc) · 1.79 KB
/
process.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#include "final.h"
static int size;
void saveNew(Mat m, string filename, string annotaion){
FileStorage classesfile(filename, FileStorage::WRITE);//FileStorage classesfile("classes.xml", FileStorage::WRITE);
classesfile << annotaion << m;//classesfile << "classes" << m;
if (classesfile.isOpened() == false){
err << "unable to open training "<<annotaion<<" in "<<filename<<endl;// file";
throw err.str();
}
classesfile.release();
}
/************************************************
process video: open and send vid to process
************************************************/
void processVideo (string filename){
VideoCapture vid;
Mat frame, framYuv;
if(!vid.open(filename)){
err << "cannot open file: \""<< filename<<"\" ." << endl;
throw err.str();
}
if (!vid.isOpened()) {
err << "error reading video file" << std::endl << std::endl;
throw err.str();
}
if (vid.get(CV_CAP_PROP_FRAME_COUNT) < 1) {
err << "video file must have at least one frame";
throw err.str();
}
const string outputfile = "fromeImages_"+filename;
//VideoWriter outputvid(outputfile);
segment (vid);
}
/************************************************
Show the frame, and write the shot count
************************************************/
void showframe(Mat& frame, int count){
string s;
if(count<0)
s = "-";
else
s = to_string(count);
putText(frame, s, Point2f(80,80), FONT_HERSHEY_PLAIN, 6.0, CV_RGB(0,0,0), 5.0);
putText(frame, s, Point2f(80,80), FONT_HERSHEY_PLAIN, 6.0, CV_RGB(0,255,0), 3.0);
Size size(frame.cols/2,frame.rows/2);
resize(frame, frame, size);
imshow("Segmentaion", frame);
waitKey(5);
}