-
Notifications
You must be signed in to change notification settings - Fork 0
/
driver.cpp
65 lines (47 loc) · 1.58 KB
/
driver.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
#include <opencv/cv.h>
#include <string>
#include <iostream>
#include "gbh.h"
#include "io.h"
using namespace std;
using namespace cv;
int main(int argc, char* argv[]) {
if (argc < 3) {
cout << "Not enough arguments" << endl;
return 1;
}
string input_path = argv[1];
int sigma = atoi(argv[2]);
int c = atoi(argv[3]);
// ------------------------------------------------------------
// Read input images
cout << "Reading Input Images" << endl;
vector<string>* paths = list_files(input_path);
// Read each image file from list of paths
vector<Mat>* images = new vector<Mat>();
for(unsigned i = 0; i < paths->size(); i++) {
string fname = paths->at(i);
Mat im = imread(fname, CV_LOAD_IMAGE_COLOR);
if(!im.data) {
cout << "Skipping non-image file " << fname << endl;
} else {
cout << fname << endl;
images->push_back(im);
}
}
// ------------------------------------------------------------
// Record start time
double time = (double)getTickCount();
// ------------------------------------------------------------
// Segment video
gbh_segment(images, sigma, c);
// ------------------------------------------------------------
// Compute time passed
time = ((double)getTickCount() - time)/getTickFrequency();
cout << "Time passed: " << time << " seconds" << endl;
// ------------------------------------------------------------
// Display results
write_images(images);
delete images;
return 0;
}