24 #include <core/exceptions/software.h> 53 unsigned int threshold,
unsigned int max_size,
54 bool use_rising_flank,
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;
113 unsigned int width,
unsigned int height)
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++)
144 _last_val = _q->
get(_last_pos);
146 while(!slm->finished())
148 cur_pos = *(++(*slm));
149 cur_val = _q->
get(cur_pos);
150 cur_diff = cur_val - _last_val;
152 if ((cur_pos.
x < _last_pos.
x || cur_pos.
y < _last_pos.
y)
154 || (cur_pos.
y - current.
start.
y) > _max_size)))
158 edge_start.
x = edge_start.
y = direction = jumpSize = 0;
161 int curDir = (cur_diff < 0 ? -1 : (cur_diff > 0 ? 1 : 0));
168 jumpSize -= cur_diff;
171 jumpSize = -cur_diff;
172 edge_start = cur_pos;
175 if (jumpSize < _threshold)
177 jumpSize = -cur_diff;
178 edge_start = cur_pos;
187 rv->push_back(
ROI(current));
191 else if (_use_falling_edge)
197 edge_start = cur_pos;
198 jumpSize = -cur_diff;
211 if (jumpSize >= _threshold)
218 rv->push_back(
ROI(current));
224 if ((_use_falling_edge && direction == 1) || (_use_rising_edge && direction == -1))
236 direction = jumpSize = 0;
237 edge_start.
x = edge_start.
y = 0;
245 jumpSize += cur_diff;
249 edge_start = cur_pos;
252 if (jumpSize < _threshold)
255 edge_start = cur_pos;
264 rv->push_back(
ROI(current));
268 else if (_use_rising_edge)
274 edge_start = cur_pos;
GradientClassifier(std::list< ScanlineGrid * > *scanlines, Qualifier *q, unsigned int threshold, unsigned int max_size=0, bool use_rising_flank=true, bool use_falling_flank=true)
Constructor.
virtual std::list< ROI > * classify()
Classify image.
void set_height(unsigned int height)
Set height of ROI.
fawkes::upoint_t start
ROI start.
unsigned int y
y coordinate
unsigned int x
x coordinate
void set_pixel_step(unsigned int step)
Set pixel step.
A NULL pointer was supplied where not allowed.
virtual void set_buffer(unsigned char *buffer, unsigned int width=0, unsigned int height=0)
buffer setter
virtual int get(fawkes::upoint_t pixel)=0
Getter.
virtual void set_edges(bool use_rising_edge, bool use_falling_edge)
Edge setter.
virtual unsigned char * get_buffer()
Get buffer.
virtual void set_src_buffer(unsigned char *yuv422_planar, unsigned int width, unsigned int height)
Set source buffer.
virtual void set_threshold(unsigned int threshold, unsigned int max_size=0)
Threshold setter.
virtual ~GradientClassifier()
Destructor.
Point with cartesian coordinates as unsigned integers.
void set_start(fawkes::upoint_t p)
Set upper left corner of ROI.
virtual void set_src_buffer(unsigned char *yuv422_planar, unsigned int width, unsigned int height)
Set source buffer.
Classifier to extract regions of interest.
unsigned int pixel_step
pixel step
void set_width(unsigned int width)
Set width of ROI.
Abstract Qualifier for a single pixel.