2
2
3
3
#include " event_batch.hpp"
4
4
#include " pontella.hpp"
5
+ #include " select_rectangle.hpp"
5
6
#include " sepia.hpp"
6
7
7
8
int
@@ -16,6 +17,10 @@ main(int argc, char* argv[])
16
17
{
17
18
uint64_t t_decay_first;
18
19
float weight_thresh;
20
+ uint16_t left;
21
+ uint16_t right;
22
+ uint16_t bottom;
23
+ uint16_t top;
19
24
};
20
25
21
26
return pontella::main (
@@ -26,16 +31,40 @@ main(int argc, char* argv[])
26
31
" defaults to 10000" ,
27
32
" -e e, --weight-threshold e sets the weight threshold" ,
28
33
" defaults to 0.1" ,
34
+ " -cl cl, --crop-left cl sets the crop's left side "
35
+ " coordinate" ,
36
+ " defaults to 0" ,
37
+ " -cr cr, --crop-right cr sets the crop's right side "
38
+ " coordinate" ,
39
+ " defaults to context width" ,
40
+ " -cb cb, --crop-bottom cb sets the crop's bottom side "
41
+ " coordinate" ,
42
+ " defaults to 0" ,
43
+ " -ct ct, --crop-top ct sets the crop's top side "
44
+ " coordinate" ,
45
+ " defaults to context height" ,
29
46
" -h, --help shows this help message" },
30
- argc, argv, 1 , {{" time-decay-first" , {" t" }}, {" weight-threshold" , {" e" }}},
47
+ argc, argv, 1 ,
48
+ {{" time-decay-first" , {" t" }},
49
+ {" weight-threshold" , {" e" }},
50
+ {" crop-left" , {" cl" }},
51
+ {" crop-right" , {" cr" }},
52
+ {" crop-bottom" , {" cb" }},
53
+ {" crop-top" , {" ct" }}},
31
54
{}, [&](pontella::command command) {
32
55
const std::string& filename = command.arguments [0 ];
56
+ const auto header =
57
+ sepia::read_header (sepia::filename_to_ifstream (filename));
33
58
34
59
Arguments arguments;
35
60
arguments.t_decay_first =
36
61
extract_argument (command, " time-decay-first" , 10000 );
37
62
arguments.weight_thresh =
38
63
extract_argument (command, " weight-threshold" , 0.1 );
64
+ arguments.left = extract_argument (command, " crop-left" , 0 );
65
+ arguments.right = extract_argument (command, " crop-right" , header.width );
66
+ arguments.bottom = extract_argument (command, " crop-bottom" , 0 );
67
+ arguments.top = extract_argument (command, " crop-top" , header.height );
39
68
40
69
Decay event_decay;
41
70
auto handle_global_decay = [&](Decay decay) { event_decay = decay; };
@@ -55,11 +84,15 @@ main(int argc, char* argv[])
55
84
auto batch = make_batch<Event>(arguments.weight_thresh , event_decay,
56
85
handle_batch);
57
86
87
+ auto crop = tarsier::make_select_rectangle<Event>(
88
+ arguments.left , arguments.bottom , arguments.right - arguments.left ,
89
+ arguments.top - arguments.bottom , [&](Event event) {
90
+ global_decay (event);
91
+ batch (event);
92
+ });
93
+
58
94
sepia::join_observable<Type>(sepia::filename_to_ifstream (filename),
59
- [&](Event event) {
60
- global_decay (event);
61
- batch (event);
62
- });
95
+ crop);
63
96
64
97
if (batch.batch ().size () > 0 )
65
98
{
0 commit comments