-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathff_watermark.cpp
More file actions
60 lines (50 loc) · 1.7 KB
/
ff_watermark.cpp
File metadata and controls
60 lines (50 loc) · 1.7 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
49
50
51
52
53
54
55
56
57
58
59
60
/*
*filename: ff_watermark.cpp
**
*** Author: Mario Leonardo Salinas
*** Student Code: 502795
*** Master Degree curriculum: Data and Knowledge - Science and Technologies
**
*/
/*
* C++&Fastflow implementation of a parallel watermark application.
* The ff_node business-logic code can can be found in lib/ff_farm.cpp.
* Lines 26-30 contain some global variables defined also in ff_farm.cpp.
**/
#include "./lib/ff_farm.cpp"
int main(int argc, char * argv[]){
if(argc < 6) {
std::cout << "Usage is: " << argv[0] << " source_folder result_folder watermark_file par_deg avg" <<
std::endl << "*************************************************" <<
std::endl << "*** Images and watermark must have SAME SIZE. ***" <<
std::endl << "*************************************************" << std::endl;
return(0);
}
watermark = cimg_library::CImg<int>(argv[3]);
path_in = std::string(argv[1]);
path_out = std::string(argv[2]);
const size_t nworkers = std::stol(argv[4]);
aVg = to_bool(argv[5]);
source src;
std::vector<std::unique_ptr<ff_node> > W;
for(size_t i=0;i<nworkers;++i){
stage1* first = new stage1();
stage2* second = new stage2();
stage3* third = new stage3();
W.push_back(make_unique<ff_Pipe<float>>(first, second, third));
}
ff_Farm<float> farm(std::move(W));
farm.add_emitter(src);
farm.remove_collector();
std::cerr << "ff_watermark\n";
ffTime(START_TIME);
if (farm.run_and_wait_end()<0) {
error("Running farm ");
return -1;
}
ffTime(STOP_TIME);
std::cout << "Time: " << ffTime(GET_TIME) <<
" nImgs: " << nImgs << " par_deg: " <<
nworkers << " source: " << path_in <<"\n";
return 0;
}