Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

RasterSpecialist Class Reference

Base-class for RasterSpecialists. More...

#include <RasterSpecialist.h>

Inheritance diagram for RasterSpecialist:

Inheritance graph
[legend]
Collaboration diagram for RasterSpecialist:

Collaboration graph
[legend]
List of all members.

Public Types

typedef const unsigned char * I_Pin

Public Member Functions

 RasterSpecialist (RasterImageProcessor &imagePro)
 The Constructor.

virtual ~RasterSpecialist ()
 The Destructor.

virtual int getType ()=0
 getter for the type of specialist

virtual void init ()=0
 Initializes the specialist before running the detection algorithm.

virtual void executePostProcessing ()
 Executes the detection algorithm.

virtual void invokeOnPreScan (int x, int y)
 Invokes the specialist in the first scan stage at position (x,y) (this member should be replaced later).

virtual void invokeOnPostScan (int x, int y)
 Invokes the specialist in the second scan stage at position (x,y) (this member should be replaced later).


Public Attributes

bool preScanNeeded
 Tells if the specialist should be invoked in the pre-scan.

bool postScanNeeded
 Tells if the specialist should be invoked in the post-scan.


Protected Member Functions

void createSegmentsFromLines (std::list< LinePair > &lines, std::vector< std::list< LinePair > > &segments, int spaceX, int spaceY)
 Runs a algorithm to cluster line pairs that might belong to one region (segment).

bool createSegmentsFromLines2 (std::list< LinePair > &lines, std::vector< std::list< LinePair > > &segments, int xSpace, int ySpace)
 Runs a algorithm to cluster line pairs that might belong to one region (segment).

bool createGridSegments (std::list< GridLP > &lines, std::vector< std::list< GridLP > > &segments, int xSpace, int ySpace)
 Runs a algorithm to cluster GridLPs that might belong to one region (segment).

bool doColorSegmentation (std::vector< LinePair > &lines, std::vector< std::vector< LinePair > > &segments, int xSpace, int ySpace)
 Runs a algorithm to cluster line pairs that might belong to one region (segment).

void createConvexPoly (std::list< LinePair > &input, std::vector< Vector2< int > > output)
 precondition: Lines must be sorted in increasing y - order.

colorClass getColor (Vector2< int > v)
 Implemented with ColorTable interface.

colorClass getColor (int x, int y)
 Implemented with ColorTable interface.

bool checkColor (int x, int y, colorClass color)
 Implemented with ColorTable interface.

bool checkColor (Vector2< int > v, colorClass color)
 Implemented with ColorTable interface.

Vector2< int > scanNorth (int x, int y)
 Scans to the top, until the colorClass(x,y) changes or the border of the image is reached.

Vector2< int > scanSouth (int x, int y)
 Scans to the bottom, until getColor(x,y) changes or the border of the image is reached.

Vector2< int > scanWest (int x, int y)
 Scans to the right side, until getColor(x,y) changes or the border of the image is reached.

Vector2< int > scanEast (int x, int y)
 Scans to the left side, until getColor(x,y) changes or the border of the image is reached.

Vector2< int > scanNW (int x, int y)
 Scans to top left, until getColor(x,y) changes or the border of the image is reached.

Vector2< int > scanSW (int x, int y)
 Scans to down left, until getColor(x,y) changes or the border of the image is reached.

Vector2< int > scanSE (int x, int y)
 Scans to down right, until getColor(x,y) changes or the border of the image is reached.

Vector2< int > scanNE (int x, int y)
 Scans to top right, until getColor(x,y) changes or the border of the image is reached.

Vector2< int > scan (Vector2< int > v, short direction)
 Scans to the give direction, until getColor(x,y) changes or the border of the image is reached.

Vector2< int > scan (Vector2< int > v, short direction, colorClass search)
 Scans in the given direction and stops if the given color is found or the border of the image is reached.

Vector2< int > scan (int x, int y, short direction)
 Scans in the given direction and stops if color changes.

float getDistanceToLine (const Geometry::Line line, const Vector2< int > &point)
 Calculates the distance to the line.

double theta (Vector2< int > &v1, Vector2< int > &v2)
 The theta function for the difference of two vectors.

double theta (Vector2< int > &v)
 The theta function.

int sign (int value)
 Helper.


Protected Attributes

RasterImageProcessorrip
 Holds the related image processor.

int const  imageHeight
 Holds the height of the image.

int const  imageWidth
 Holds the width of the image.

Vector2< int > errorDummy
 A helper variable.


Private Member Functions

bool linePairsFit (LinePair &inSegment,LinePair &newPair, int allowedSpace)
 Tests if two runs have a distance smaller than the allowed space.

bool gridFit (GridLP &inSegment,GridLP &newPair, int allowedSpace)
 Tests if two runs have a distance smaller than the allowed space.

bool linesFit (LinePair &inSegment,LinePair &newPair, int allowedSpace)
 Tests if two runs have a distance smaller than the allowed space and if their color is the same.


Private Attributes

int currentX
 A temporary variable for the direction offset.

int currentY
 A temporary variable for the direction offset.

colorClass search
 A temporary variable.

int const  Y_VALUE
 Offset value for Y channel.

int const  U_VALUE
 Offset value for U channel.

int const  V_VALUE
 Offset value for V channel.

std::list< std::list< LinePair > > segList
 List for segmentation functions.


Detailed Description

Base-class for RasterSpecialists.

A RasterSpecialist is detecting shapes in the image.

Author:
Bernd Schmidt

Definition at line 36 of file RasterSpecialist.h.


Member Typedef Documentation

typedef const unsigned char* RasterSpecialist::I_Pin
 

Reimplemented in REnemySpecialist.

Definition at line 199 of file RasterSpecialist.h.


Constructor & Destructor Documentation

RasterSpecialist::RasterSpecialist RasterImageProcessor imagePro  ) 
 

The Constructor.

For creation the RasterImageProcessor is needed.

Parameters:
imagePro The ImageProcessor the specialist belongs to.

Definition at line 14 of file RasterSpecialist.cpp.

References cameraResolutionHeight_ERS7, cameraResolutionWidth_ERS7, postScanNeeded, preScanNeeded, and Y_VALUE.

RasterSpecialist::~RasterSpecialist  )  [virtual]
 

The Destructor.

Definition at line 26 of file RasterSpecialist.cpp.


Member Function Documentation

virtual int RasterSpecialist::getType  )  [pure virtual]
 

getter for the type of specialist

Returns:
The type of the specialist.

Implemented in BoxSpecialist, RBallSpecialist2, RBridgeSpecialist, REnemySpecialist, and RFieldSpecialist.

Referenced by RasterImageProcessor::setSpecialist().

virtual void RasterSpecialist::init  )  [pure virtual]
 

Initializes the specialist before running the detection algorithm.

Implemented in BoxSpecialist, RBallSpecialist2, RBridgeSpecialist, REnemySpecialist, and RFieldSpecialist.

virtual void RasterSpecialist::executePostProcessing  )  [inline, virtual]
 

Executes the detection algorithm.

Reimplemented in BoxSpecialist, RBallSpecialist2, RBridgeSpecialist, REnemySpecialist, and RFieldSpecialist.

Definition at line 216 of file RasterSpecialist.h.

virtual void RasterSpecialist::invokeOnPreScan int  x,
int  y
[inline, virtual]
 

Invokes the specialist in the first scan stage at position (x,y) (this member should be replaced later).

Parameters:
x The x coordinate.
y The y coordinate.

Reimplemented in BoxSpecialist, RBallSpecialist2, RBridgeSpecialist, REnemySpecialist, and RFieldSpecialist.

Definition at line 222 of file RasterSpecialist.h.

virtual void RasterSpecialist::invokeOnPostScan int  x,
int  y
[inline, virtual]
 

Invokes the specialist in the second scan stage at position (x,y) (this member should be replaced later).

Parameters:
x The x coordinate.
y The y coordinate.

Reimplemented in BoxSpecialist, RBallSpecialist2, RBridgeSpecialist, REnemySpecialist, and RFieldSpecialist.

Definition at line 228 of file RasterSpecialist.h.

void RasterSpecialist::createSegmentsFromLines std::list< LinePair > &  lines,
std::vector< std::list< LinePair > > &  segments,
int  spaceX,
int  spaceY
[protected]
 

Runs a algorithm to cluster line pairs that might belong to one region (segment).

preconstraint: Lines must be sorted in increasing x - order

Parameters:
lines The lines to cluster.
segments The output as a vector.
spaceX Allowed space between two pairs in x-dimension.
spaceY Allowed space between two pairs in y-direction.

Definition at line 218 of file RasterSpecialist.cpp.

References idText, linePairsFit(), OUTPUT, segList, RasterSpecialist::LinePair::v1, and Vector2< int >::y.

Here is the call graph for this function:

bool RasterSpecialist::createSegmentsFromLines2 std::list< LinePair > &  lines,
std::vector< std::list< LinePair > > &  segments,
int  xSpace,
int  ySpace
[protected]
 

Runs a algorithm to cluster line pairs that might belong to one region (segment).

preconstraint: Lines must be sorted in increasing y - order

Parameters:
lines The lines to cluster.
segments The output as a vector.
xSpace Allowed space between two pairs in x-dimension.
ySpace Allowed space between two pairs in y-direction.
Returns:

Definition at line 135 of file RasterSpecialist.cpp.

References linePairsFit().

Referenced by REnemySpecialist::executePostProcessing(), RBridgeSpecialist::executePostProcessing(), RBallSpecialist2::executePostProcessing(), and BoxSpecialist::executePostProcessing().

Here is the call graph for this function:

bool RasterSpecialist::createGridSegments std::list< GridLP > &  lines,
std::vector< std::list< GridLP > > &  segments,
int  xSpace,
int  ySpace
[protected]
 

Runs a algorithm to cluster GridLPs that might belong to one region (segment).

The segmantation process is calculated in the coordinate system of the grid.

preconstraint: Lines must be sorted in increasing y - order

Parameters:
lines The lines to cluster.
segments The output as a vector.
xSpace Allowed space between two pairs in x-dimension.
ySpace Allowed space between two pairs in y-direction.
Returns:

Definition at line 55 of file RasterSpecialist.cpp.

References gridFit().

Here is the call graph for this function:

bool RasterSpecialist::doColorSegmentation std::vector< LinePair > &  lines,
std::vector< std::vector< LinePair > > &  segments,
int  xSpace,
int  ySpace
[protected]
 

Runs a algorithm to cluster line pairs that might belong to one region (segment).

Two line pairs only will belong to one region, if the color of the two line pairs is the same.

preconstraint: Lines must be sorted in increasing y - order

Parameters:
lines The lines to cluster.
segments The output as a vector.
xSpace Allowed space between two pairs in x-dimension.
ySpace Allowed space between two pairs in y-direction.
Returns:

Definition at line 335 of file RasterSpecialist.cpp.

References idText, linesFit(), and OUTPUT.

Here is the call graph for this function:

void RasterSpecialist::createConvexPoly std::list< LinePair > &  input,
std::vector< Vector2< int > >  output
[protected]
 

precondition: Lines must be sorted in increasing y - order.

Parameters:
input A region.
output A vector of points, that represents the polygon.

Definition at line 416 of file RasterSpecialist.cpp.

References theta().

Here is the call graph for this function:

colorClass RasterSpecialist::getColor Vector2< int >  v  )  [inline, protected]
 

Implemented with ColorTable interface.

Parameters:
v Input pixel.
Returns:
The classified color of the pixel.

Definition at line 310 of file RasterSpecialist.h.

References colorClass, Vector2< V >::x, and Vector2< V >::y.

Referenced by checkColor(), BoxSpecialist::createBBox(), REnemySpecialist::executePostProcessing(), RBridgeSpecialist::findBridgeMark(), RBridgeSpecialist::getPosition(), RBridgeSpecialist::invokeOnPreScan(), BoxSpecialist::invokeOnPreScan(), scan(), scanEast(), scanNE(), scanNorth(), scanNW(), scanSE(), scanSouth(), scanSW(), scanWest(), and RBallSpecialist2::validateCircle().

colorClass RasterSpecialist::getColor int  x,
int  y
[inline, protected]
 

Implemented with ColorTable interface.

Parameters:
x X-coordinate of the requested pixel.
y Y-coordinate of the requested pixel.
Returns:
The classified color of the pixel.

Definition at line 318 of file RasterSpecialist.h.

References colorClass, ImageProcessorInterfaces::colorTable, ColorCorrector::correct(), ColorTable::getColorClass(), Image::image, and ImageProcessorInterfaces::image.

Here is the call graph for this function:

bool RasterSpecialist::checkColor int  x,
int  y,
colorClass  color
[inline, protected]
 

Implemented with ColorTable interface.

Parameters:
x X-coordinate of the requested pixel.
y Y-coordinate of the requested pixel.
color The color class to match.
Returns:
True if color equals getColor(x,y).

Definition at line 331 of file RasterSpecialist.h.

References getColor().

Referenced by scan(), scanEast(), scanNE(), scanNorth(), scanNW(), scanSE(), scanSouth(), scanSW(), and scanWest().

Here is the call graph for this function:

bool RasterSpecialist::checkColor Vector2< int >  v,
colorClass  color
[inline, protected]
 

Implemented with ColorTable interface.

Parameters:
v The requested pixel.
color The color class to match.
Returns:
True if color equals getColor(x,y).

Definition at line 339 of file RasterSpecialist.h.

References getColor(), Vector2< V >::x, and Vector2< V >::y.

Here is the call graph for this function:

Vector2<int> RasterSpecialist::scanNorth int  x,
int  y
[inline, protected]
 

Scans to the top, until the colorClass(x,y) changes or the border of the image is reached.

Parameters:
x x-coordinate of the start
y y-coordinate of the start
Returns:
Last pixel with the same colorClass of the given position represented as a Vector2<int>.

Definition at line 351 of file RasterSpecialist.h.

References checkColor(), getColor(), search, Vector2< V >::x, and Vector2< V >::y.

Here is the call graph for this function:

Vector2<int> RasterSpecialist::scanSouth int  x,
int  y
[inline, protected]
 

Scans to the bottom, until getColor(x,y) changes or the border of the image is reached.

Parameters:
x x-coordinate of the start
y y-coordinate of the start
Returns:
Last pixel with the same colorClass of the given position represented as a Vector2<int>.

Definition at line 368 of file RasterSpecialist.h.

References checkColor(), getColor(), search, Vector2< V >::x, and Vector2< V >::y.

Here is the call graph for this function:

Vector2<int> RasterSpecialist::scanWest int  x,
int  y
[inline, protected]
 

Scans to the right side, until getColor(x,y) changes or the border of the image is reached.

Parameters:
x x-coordinate of the start
y y-coordinate of the start
Returns:
Last pixel with the same colorClass of the given position represented as a Vector2<int>.

Definition at line 383 of file RasterSpecialist.h.

References checkColor(), getColor(), search, Vector2< V >::x, and Vector2< V >::y.

Referenced by RBridgeSpecialist::invokeOnPreScan().

Here is the call graph for this function:

Vector2<int> RasterSpecialist::scanEast int  x,
int  y
[inline, protected]
 

Scans to the left side, until getColor(x,y) changes or the border of the image is reached.

Parameters:
x x-coordinate of the start
y y-coordinate of the start
Returns:
Last pixel with the same colorClass of the given position represented as a Vector2<int>.

Definition at line 398 of file RasterSpecialist.h.

References checkColor(), getColor(), search, Vector2< V >::x, and Vector2< V >::y.

Referenced by RBridgeSpecialist::invokeOnPreScan().

Here is the call graph for this function:

Vector2<int> RasterSpecialist::scanNW int  x,
int  y
[inline, protected]
 

Scans to top left, until getColor(x,y) changes or the border of the image is reached.

Parameters:
x x-coordinate of the start
y y-coordinate of the start
Returns:
Last pixel with the same colorClass of the given position represented as a Vector2<int>.

Definition at line 412 of file RasterSpecialist.h.

References checkColor(), getColor(), search, Vector2< V >::x, and Vector2< V >::y.

Here is the call graph for this function:

Vector2<int> RasterSpecialist::scanSW int  x,
int  y
[inline, protected]
 

Scans to down left, until getColor(x,y) changes or the border of the image is reached.

Parameters:
x x-coordinate of the start
y y-coordinate of the start
Returns:
Last pixel with the same colorClass of the given position represented as a Vector2<int>.

Definition at line 430 of file RasterSpecialist.h.

References checkColor(), getColor(), search, Vector2< V >::x, and Vector2< V >::y.

Here is the call graph for this function:

Vector2<int> RasterSpecialist::scanSE int  x,
int  y
[inline, protected]
 

Scans to down right, until getColor(x,y) changes or the border of the image is reached.

Parameters:
x x-coordinate of the start
y y-coordinate of the start
Returns:
Last pixel with the same colorClass of the given position represented as a Vector2<int>.

Definition at line 448 of file RasterSpecialist.h.

References checkColor(), getColor(), search, Vector2< V >::x, and Vector2< V >::y.

Here is the call graph for this function:

Vector2<int> RasterSpecialist::scanNE int  x,
int  y
[inline, protected]
 

Scans to top right, until getColor(x,y) changes or the border of the image is reached.

Parameters:
x x-coordinate of the start
y y-coordinate of the start
Returns:
Last pixel with the same colorClass of the given position represented as a Vector2<int>.

Definition at line 465 of file RasterSpecialist.h.

References checkColor(), getColor(), search, Vector2< V >::x, and Vector2< V >::y.

Here is the call graph for this function:

Vector2<int> RasterSpecialist::scan Vector2< int >  v,
short  direction
[inline, protected]
 

Scans to the give direction, until getColor(x,y) changes or the border of the image is reached.

Parameters:
v coordinates of the start
direction the scan-direction
Returns:
Last pixel with the same colorClass of the given position represented as a Vector2<int>.

Definition at line 482 of file RasterSpecialist.h.

References checkColor(), currentX, currentY, errorDummy, getColor(), search, Vector2< V >::x, and Vector2< V >::y.

Referenced by scan().

Here is the call graph for this function:

Vector2<int> RasterSpecialist::scan Vector2< int >  v,
short  direction,
colorClass  search
[inline, protected]
 

Scans in the given direction and stops if the given color is found or the border of the image is reached.

Parameters:
v coordinates of the start
search colorClass to search for
direction the scan-direction
Returns:
The first pixel where the expression (search == getColor(x,y)) is true.

Definition at line 540 of file RasterSpecialist.h.

References checkColor(), currentX, currentY, errorDummy, Vector2< V >::x, and Vector2< V >::y.

Here is the call graph for this function:

Vector2<int> RasterSpecialist::scan int  x,
int  y,
short  direction
[inline, protected]
 

Scans in the given direction and stops if color changes.

Parameters:
x x-coordinate of the start
y y-coordinate of the start
direction the scan-direction
Returns:
The last pixel with the same color as the start pixel.

Definition at line 594 of file RasterSpecialist.h.

References scan().

Here is the call graph for this function:

float RasterSpecialist::getDistanceToLine const Geometry::Line  line,
const Vector2< int > &  point
[inline, protected]
 

Calculates the distance to the line.

Parameters:
line the line
point the point
Returns:
the distance of the point to the line

Definition at line 602 of file RasterSpecialist.h.

References Geometry::Line::base, Geometry::Line::direction, Geometry::distance(), Vector2< V >::normalize(), point, Vector2< V >::x, Vector2< double >::x, Vector2< int >::x, Vector2< V >::y, Vector2< double >::y, and Vector2< int >::y.

Referenced by RBridgeSpecialist::createBBox(), BoxSpecialist::createBBox(), RBridgeSpecialist::findBridgeMark(), and BoxSpecialist::searchGoal().

Here is the call graph for this function:

double RasterSpecialist::theta Vector2< int > &  v1,
Vector2< int > &  v2
[inline, protected]
 

The theta function for the difference of two vectors.

Parameters:
v1 First vector.
v2 Second vector.
Returns:
A number between 0 and 360 with the same order as v.angle() .

Definition at line 623 of file RasterSpecialist.h.

References Vector2< V >::x, and Vector2< V >::y.

Referenced by createConvexPoly().

double RasterSpecialist::theta Vector2< int > &  v  )  [inline, protected]
 

The theta function.

Parameters:
v the input
Returns:
a number between 0 and 360 with the same order as v.angle()

Definition at line 639 of file RasterSpecialist.h.

References Vector2< V >::x, and Vector2< V >::y.

int RasterSpecialist::sign int  value  )  [inline, protected]
 

Helper.

Parameters:
value the input
Returns:
sign of the given value.

Definition at line 653 of file RasterSpecialist.h.

bool RasterSpecialist::linePairsFit LinePair inSegment,
LinePair newPair,
int  allowedSpace
[inline, private]
 

Tests if two runs have a distance smaller than the allowed space.

Parameters:
inSegment First run.
newPair Second run.
allowedSpace The allowed space between the pairs. The value may also be negative.
Returns:
True, if the distance is smaller than allowedSpace.

Definition at line 680 of file RasterSpecialist.h.

References RasterSpecialist::LinePair::v1, RasterSpecialist::LinePair::v2, and Vector2< int >::x.

Referenced by createSegmentsFromLines(), and createSegmentsFromLines2().

bool RasterSpecialist::gridFit GridLP inSegment,
GridLP newPair,
int  allowedSpace
[inline, private]
 

Tests if two runs have a distance smaller than the allowed space.

Parameters:
inSegment First run.
newPair Second run.
allowedSpace The allowed space between the pairs. The value may also be negative.
Returns:
True, if the distance is smaller than allowedSpace.

Definition at line 691 of file RasterSpecialist.h.

References RasterSpecialist::GridLP::d1, and RasterSpecialist::GridLP::d2.

Referenced by createGridSegments().

bool RasterSpecialist::linesFit LinePair inSegment,
LinePair newPair,
int  allowedSpace
[inline, private]
 

Tests if two runs have a distance smaller than the allowed space and if their color is the same.

Parameters:
inSegment First run.
newPair Second run.
allowedSpace The allowed space between the pairs. The value may also be negative.
Returns:
True, if the distance is smaller than allowedSpace and the color is equal.

Definition at line 704 of file RasterSpecialist.h.

References RasterSpecialist::LinePair::color, RasterSpecialist::LinePair::v1, RasterSpecialist::LinePair::v2, and Vector2< int >::x.

Referenced by doColorSegmentation().


Member Data Documentation

bool RasterSpecialist::preScanNeeded
 

Tells if the specialist should be invoked in the pre-scan.

Definition at line 231 of file RasterSpecialist.h.

Referenced by RDefaultStrategy::init(), RDefaultStrategy::preScan(), and RasterSpecialist().

bool RasterSpecialist::postScanNeeded
 

Tells if the specialist should be invoked in the post-scan.

Definition at line 233 of file RasterSpecialist.h.

Referenced by RasterSpecialist().

RasterImageProcessor* RasterSpecialist::rip [protected]
 

Holds the related image processor.

Definition at line 237 of file RasterSpecialist.h.

int const RasterSpecialist::imageHeight [protected]
 

Holds the height of the image.

Definition at line 239 of file RasterSpecialist.h.

int const RasterSpecialist::imageWidth [protected]
 

Holds the width of the image.

Definition at line 241 of file RasterSpecialist.h.

Vector2<int> RasterSpecialist::errorDummy [protected]
 

A helper variable.

Definition at line 243 of file RasterSpecialist.h.

Referenced by scan().

int RasterSpecialist::currentX [private]
 

A temporary variable for the direction offset.

Definition at line 659 of file RasterSpecialist.h.

Referenced by scan().

int RasterSpecialist::currentY [private]
 

A temporary variable for the direction offset.

Definition at line 661 of file RasterSpecialist.h.

Referenced by scan().

colorClass RasterSpecialist::search [private]
 

A temporary variable.

Definition at line 663 of file RasterSpecialist.h.

Referenced by scan(), scanEast(), scanNE(), scanNorth(), scanNW(), scanSE(), scanSouth(), scanSW(), and scanWest().

int const RasterSpecialist::Y_VALUE [private]
 

Offset value for Y channel.

Definition at line 665 of file RasterSpecialist.h.

int const RasterSpecialist::U_VALUE [private]
 

Offset value for U channel.

Definition at line 667 of file RasterSpecialist.h.

int const RasterSpecialist::V_VALUE [private]
 

Offset value for V channel.

Definition at line 669 of file RasterSpecialist.h.

std::list<std::list<LinePair> > RasterSpecialist::segList [private]
 

List for segmentation functions.

Definition at line 671 of file RasterSpecialist.h.

Referenced by createSegmentsFromLines().


The documentation for this class was generated from the following files:
Generated on Thu Sep 23 20:11:02 2004 for GT2004 by doxygen 1.3.6