25 #include <core/exceptions/software.h>
32 namespace firevision {
51 unsigned int threshold,
52 unsigned int max_size,
53 bool use_rising_flank,
54 bool use_falling_flank)
62 _scanlines = scanlines;
67 set_edges(use_rising_flank, use_falling_flank);
85 _threshold = threshold;
100 _use_rising_edge = use_rising_edge;
101 _use_falling_edge = use_falling_edge;
126 return new std::list<ROI>;
129 list<ROI> *rv =
new list<ROI>;
130 int cur_val, cur_diff, direction = 0;
132 cur_pos.
x = cur_pos.
y = edge_start.
x = edge_start.
y = 0;
134 unsigned int jumpSize = 0;
138 for (list<ScanlineGrid *>::iterator it = _scanlines->begin(); it != _scanlines->end(); it++) {
143 _last_val = _q->
get(_last_pos);
145 while (!slm->finished()) {
146 cur_pos = *(++(*slm));
147 cur_val = _q->
get(cur_pos);
148 cur_diff = cur_val - _last_val;
150 if ((cur_pos.
x < _last_pos.
x || cur_pos.
y < _last_pos.
y)
152 && ((cur_pos.
x - current.
start.
x) > _max_size
153 || (cur_pos.
y - current.
start.
y) > _max_size))) {
156 edge_start.
x = edge_start.
y = direction = jumpSize = 0;
159 int curDir = (cur_diff < 0 ? -1 : (cur_diff > 0 ? 1 : 0));
164 jumpSize -= cur_diff;
167 jumpSize = -cur_diff;
168 edge_start = cur_pos;
171 if (jumpSize < _threshold)
173 jumpSize = -cur_diff;
174 edge_start = cur_pos;
182 rv->push_back(
ROI(current));
185 }
else if (_use_falling_edge) {
190 edge_start = cur_pos;
191 jumpSize = -cur_diff;
202 if (jumpSize >= _threshold)
209 rv->push_back(
ROI(current));
213 if ((_use_falling_edge && direction == 1) || (_use_rising_edge && direction == -1)) {
223 direction = jumpSize = 0;
224 edge_start.
x = edge_start.
y = 0;
230 jumpSize += cur_diff;
234 edge_start = cur_pos;
237 if (jumpSize < _threshold)
240 edge_start = cur_pos;
248 rv->push_back(
ROI(current));
251 }
else if (_use_rising_edge) {
256 edge_start = cur_pos;