31 #ifndef EDGE_TRACKER_H
32 #define EDGE_TRACKER_H
34 #include <drain/image/ProbingControl.h>
37 #include "CoordinateHandler.h"
38 #include "Direction.h"
39 #include "ImageChannel.h"
40 #include "ImageFile.h"
50 typedef std::list<drain::image::Position> Contour;
72 template <
class S,
class D>
78 Direction::value_t dir = Direction::NONE;
81 Direction::value_t startDir = Direction::NONE;
103 void setStart(
const Position & startPos, Direction::value_t startDir){
106 this->startPos = startPos;
107 this->startDir = startDir;
115 mout.
accept<LOG_WARNING>(
"From ", pos,
" to: ", Direction::arrows[dir],
' ',
'<', dir ,
'>');
119 if (
control.move(p, dir) == ProberControl::MOVE_ACCEPTED){
120 if (
control.isValidPixel(src, p)){
121 mout.
accept<LOG_WARNING>(p);
123 contour.push_back(pos);
124 dir = DIR_TURN_DEG(dir, 225);
133 mout.
pending<LOG_WARNING>(
" outside segment, keeping ", pos);
136 dir = DIR_TURN_DEG(dir, 45);
140 mout.
reject<LOG_WARNING>(
"illegal move");
142 dir = DIR_TURN_DEG(dir, 45);
146 return (! (dir == startDir) && (pos == startPos) );
165 setStart(startPos, startDir);
167 mout.
accept<LOG_WARNING>(
"Start ", pos,
':', Direction::arrows[dir],
' ',
'<', dir ,
'>');
171 mout.
accept<LOG_WARNING>(
"Tracking ", pos,
':', Direction::arrows[dir]);
205 mout.
note(
"Writing debug image");
207 ImageFile::write(
control.markerImage,
"edge.png");
260 template <
class S,
class D>
261 std::ostream & operator<<(std::ostream & ostr,
const EdgeTracker<S,D> & prober){
LogSourc e is the means for a function or any program segment to "connect" to a Log.
Definition: Log.h:308
Logger & pending(const TT &... args)
Report a conditional accept/reject, to be completed next.
Definition: Log.h:592
Logger & accept(const TT &... args)
Some input has been accepted, for example by a syntax.
Definition: Log.h:578
Logger & reject(const TT &... args)
Some input has been rejected, for example by a syntax.
Definition: Log.h:606
Logger & note(const TT &... args)
For top-level information.
Definition: Log.h:485
Image with static geometry.
Definition: ImageChannel.h:60
Container for parameters of SegmentProber.
Definition: EdgeTracker.h:73
ProberControl & control
A convenience function for traversing a whole image.
Definition: EdgeTracker.h:243
void track(const Position &startPos, Direction::value_t startDir)
Definition: EdgeTracker.h:161
virtual void init()
Called after src and dst have been set, but before processing. See clear().
Definition: EdgeTracker.h:220
virtual void setGeometry(size_t width, size_t height, size_t imageChannels=1, size_t alphaChannels=0)
Resizes the image, keeps the current type.
Definition: Image.h:95
Definition: DataSelector.cpp:1277
Definition: Direction.h:46
Container for parameters of SegmentProber.
Definition: ProbingControl.h:60