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

RBallSpecialist2 Class Reference

Implements a detection algorithm for balls. More...

#include <RBallSpecialist2.h>

Inheritance diagram for RBallSpecialist2:

Inheritance graph
[legend]
Collaboration diagram for RBallSpecialist2:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 RBallSpecialist2 (RasterImageProcessor &processor, RasterStrategy &strategy)
 Constructor.

virtual ~RBallSpecialist2 ()
 Destructor.

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

void executePostProcessing ()
 Executes the detection algorithm.

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 int getType ()
 Getter for the type.

virtual void init ()
 Initializes the specialist.

double validateCircle (Geometry::Circle &circle)
 Validates the circle, by comparing it to a color pattern.

double validateEdgePoints (Geometry::Circle &circle)
 Validates the circle, by calculating the percantage of edge points near the circle.

void getCoordinatesByAngle (double angle, double &x, double &y)
 Calculates the coordinates of a vector that looks in direction angle.


Public Attributes

Vector2< int > temp
 A temporary variable.

std::list< LinePairrows
 The runs to analyze.


Private Types

enum  {
  MAX_EDGE_POINTS = 30, MAX_CIRCLE_DIST = 2, EDGE_THR = 30,
  SCAN_THR = 30
}

Private Member Functions

void addBallPercept (Geometry::Circle &circle, double validity)
 Adds the Ball to the BallPercept.

double calculateSmallCircle (Geometry::Circle &circle)
 Approximates a circle for small regions.

double calculateCircleByEdges (Geometry::Circle &circle)
 Approximates the circle with a randomized algorithm.

double calculateLargeCircle (const Box &input, Geometry::Circle &circle)
 Approximates the circle with a randomized algorithm.

bool filterBallPoints (std::list< LinePair > &segment)
 Filters the edge points with a contrast filter.

bool createBox (std::list< LinePair > &segment, Box &box)
 Builds a bounding box for a segment.

double middleEdgePointDist (Geometry::Circle &circle)
 Calculates the average distance of the edge points to the circle.

bool isEdge (int x, int y)
 The function defines a filter used in filterBallPoints().

void setThreshold (int threshold)
 Setter for the edge filter threshold.


Private Attributes

RasterStrategystrategy
 The strategy.

REdgeDetection edgeScanner
 The edge detector.

int threshold
 The normal threshold.

int minEdgeThreshold
 The threshold for large balls.

std::vector< Vector2< int > > points
 A buffer for the edge points of a region.

int numberOfEdgePoints
 The number of edge points.

double roundness
 The roundness of the last detected circle.


Detailed Description

Implements a detection algorithm for balls.

Definition at line 29 of file RBallSpecialist2.h.


Member Enumeration Documentation

anonymous enum [private]
 

Enumeration values:
MAX_EDGE_POINTS 
MAX_CIRCLE_DIST 
EDGE_THR 
SCAN_THR 

Definition at line 32 of file RBallSpecialist2.h.


Constructor & Destructor Documentation

RBallSpecialist2::RBallSpecialist2 RasterImageProcessor processor,
RasterStrategy strategy
 

Constructor.

Parameters:
processor The image processor interfaces.
strategy The strategy.

Definition at line 19 of file RBallSpecialist2.cpp.

References InFile::exists(), getLocation(), idText, minEdgeThreshold, and OUTPUT.

Here is the call graph for this function:

RBallSpecialist2::~RBallSpecialist2  )  [virtual]
 

Destructor.

Definition at line 47 of file RBallSpecialist2.cpp.


Member Function Documentation

void RBallSpecialist2::invokeOnPostScan int  x,
int  y
[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 from RasterSpecialist.

Definition at line 114 of file RBallSpecialist2.cpp.

void RBallSpecialist2::executePostProcessing  )  [virtual]
 

Executes the detection algorithm.

Reimplemented from RasterSpecialist.

Definition at line 52 of file RBallSpecialist2.cpp.

References addBallPercept(), calculateCircleByEdges(), calculateLargeCircle(), calculateSmallCircle(), Image::cameraInfo, createBox(), RasterSpecialist::createSegmentsFromLines2(), filterBallPoints(), ImageProcessorInterfaces::image, RasterSpecialist::Box::maxX, RasterSpecialist::Box::maxY, minEdgeThreshold, RasterSpecialist::Box::minX, RasterSpecialist::Box::minY, numberOfEdgePoints, CameraInfo::resolutionHeight, rows, and REdgeDetection::threshold.

Referenced by RDefaultStrategy::postProcessing().

Here is the call graph for this function:

void RBallSpecialist2::invokeOnPreScan int  x,
int  y
[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 from RasterSpecialist.

Definition at line 96 of file RBallSpecialist2.cpp.

References RasterStrategy::insideBall, LINE, rows, and temp.

Referenced by RDefaultStrategy::checkBall(), and RDefaultStrategy::preScan().

int RBallSpecialist2::getType  )  [virtual]
 

Getter for the type.

Returns:
The type of the specialist.

Implements RasterSpecialist.

Definition at line 118 of file RBallSpecialist2.cpp.

References __RBallSpecialist.

void RBallSpecialist2::init  )  [virtual]
 

Initializes the specialist.

Implements RasterSpecialist.

Definition at line 123 of file RBallSpecialist2.cpp.

References minEdgeThreshold, roundness, rows, and REdgeDetection::threshold.

Referenced by RDefaultStrategy::init().

double RBallSpecialist2::validateCircle Geometry::Circle circle  ) 
 

Validates the circle, by comparing it to a color pattern.

Parameters:
circle The circle.
Returns:
The validity.

Definition at line 187 of file RBallSpecialist2.cpp.

References Image::cameraInfo, Geometry::Circle::center, colorClass, DOT, RasterSpecialist::getColor(), ImageProcessorInterfaces::image, Geometry::insideCircle(), Geometry::Circle::radius, CameraInfo::resolutionHeight, CameraInfo::resolutionWidth, Vector2< double >::x, and Vector2< double >::y.

Referenced by calculateCircleByEdges(), and calculateSmallCircle().

Here is the call graph for this function:

double RBallSpecialist2::validateEdgePoints Geometry::Circle circle  ) 
 

Validates the circle, by calculating the percantage of edge points near the circle.

Parameters:
circle The circle.
Returns:
The validity of the circle.

Definition at line 326 of file RBallSpecialist2.cpp.

References Geometry::Circle::center, MAX_CIRCLE_DIST, numberOfEdgePoints, and Geometry::Circle::radius.

Referenced by calculateCircleByEdges().

void RBallSpecialist2::getCoordinatesByAngle double  angle,
double &  x,
double &  y
[inline]
 

Calculates the coordinates of a vector that looks in direction angle.

Only a helper.

Parameters:
angle input
x output variable
y output variable

Definition at line 82 of file RBallSpecialist2.h.

Referenced by calculateLargeCircle().

void RBallSpecialist2::addBallPercept Geometry::Circle circle,
double  validity
[private]
 

Adds the Ball to the BallPercept.

Makes some small tests befor generating a percept.

Parameters:
circle The circle detected as a ball.
validity The color validity for this circle.

Definition at line 135 of file RBallSpecialist2.cpp.

References BallPercept::add(), ImageProcessorInterfaces::ballPercept, Geometry::calculateAnglesForPoint(), Geometry::calculatePointOnField(), Image::cameraInfo, ImageProcessorInterfaces::cameraMatrix, Geometry::Circle::center, CIRCLE, Geometry::getDistanceToLine(), RasterImageProcessor::getHorizon(), ImageProcessorInterfaces::image, CameraMatrix::isValid, Geometry::Circle::radius, roundness, Pose3D::translation, Vector2< V >::x, Vector2< double >::x, Vector2< V >::y, and Vector2< double >::y.

Referenced by executePostProcessing().

Here is the call graph for this function:

double RBallSpecialist2::calculateSmallCircle Geometry::Circle circle  )  [private]
 

Approximates a circle for small regions.

Parameters:
circle The circle.
Returns:
Validity of the circle.

Definition at line 469 of file RBallSpecialist2.cpp.

References Geometry::Circle::center, Geometry::getCircle(), numberOfEdgePoints, Geometry::Circle::radius, roundness, validateCircle(), Vector2< double >::x, and Vector2< double >::y.

Referenced by executePostProcessing().

Here is the call graph for this function:

double RBallSpecialist2::calculateCircleByEdges Geometry::Circle circle  )  [private]
 

Approximates the circle with a randomized algorithm.

Parameters:
circle The result.
Returns:
The validity of the result.

Definition at line 354 of file RBallSpecialist2.cpp.

References Geometry::getCircle(), middleEdgePointDist(), numberOfEdgePoints, roundness, validateCircle(), and validateEdgePoints().

Referenced by calculateLargeCircle(), and executePostProcessing().

Here is the call graph for this function:

double RBallSpecialist2::calculateLargeCircle const Box &  input,
Geometry::Circle circle
[private]
 

Approximates the circle with a randomized algorithm.

Edge points are filtered with a star scan, which has its origin in the center of the box.

Parameters:
input The bounding box of the region seems to belong to a ball.
circle The result.
Returns:
The validity of the result.

Definition at line 430 of file RBallSpecialist2.cpp.

References calculateCircleByEdges(), getCoordinatesByAngle(), LINE, MAX_EDGE_POINTS, numberOfEdgePoints, pi2, REdgeDetection::scan(), Vector2< V >::x, and Vector2< V >::y.

Referenced by executePostProcessing().

Here is the call graph for this function:

bool RBallSpecialist2::filterBallPoints std::list< LinePair > &  segment  )  [private]
 

Filters the edge points with a contrast filter.

Parameters:
segment The region, which is the input data.
Returns:
True, if selected more than 3 points.

Definition at line 270 of file RBallSpecialist2.cpp.

References DOT, isEdge(), MAX_EDGE_POINTS, numberOfEdgePoints, temp, and Vector2< int >::y.

Referenced by executePostProcessing().

Here is the call graph for this function:

bool RBallSpecialist2::createBox std::list< LinePair > &  segment,
Box &  box
[private]
 

Builds a bounding box for a segment.

Parameters:
segment The input data.
box The result.
Returns:
True, if building was succesful.

Definition at line 382 of file RBallSpecialist2.cpp.

References LINE, RasterSpecialist::Box::maxX, RasterSpecialist::Box::maxY, RasterSpecialist::Box::minX, RasterSpecialist::Box::minY, temp, and Vector2< int >::y.

Referenced by executePostProcessing().

double RBallSpecialist2::middleEdgePointDist Geometry::Circle circle  )  [private]
 

Calculates the average distance of the edge points to the circle.

Parameters:
circle The circle.
Returns:
The average distance of all edge points.

Definition at line 341 of file RBallSpecialist2.cpp.

References Geometry::Circle::center, numberOfEdgePoints, and Geometry::Circle::radius.

Referenced by calculateCircleByEdges().

bool RBallSpecialist2::isEdge int  x,
int  y
[inline, private]
 

The function defines a filter used in filterBallPoints().

Parameters:
x The x-coordinate.
y The y-coordinate.
Returns:
True if the point lies on a edge.

Definition at line 165 of file RBallSpecialist2.h.

References REdgeDetection::isHorizontalEdge(), and REdgeDetection::isVerticalEdge().

Referenced by filterBallPoints().

Here is the call graph for this function:

void RBallSpecialist2::setThreshold int  threshold  )  [private]
 

Setter for the edge filter threshold.

Parameters:
threshold A threshold.

Definition at line 505 of file RBallSpecialist2.cpp.


Member Data Documentation

Vector2<int> RBallSpecialist2::temp
 

A temporary variable.

Definition at line 88 of file RBallSpecialist2.h.

Referenced by createBox(), filterBallPoints(), and invokeOnPreScan().

std::list<LinePair> RBallSpecialist2::rows
 

The runs to analyze.

Definition at line 90 of file RBallSpecialist2.h.

Referenced by executePostProcessing(), init(), and invokeOnPreScan().

RasterStrategy* RBallSpecialist2::strategy [private]
 

The strategy.

Definition at line 94 of file RBallSpecialist2.h.

REdgeDetection RBallSpecialist2::edgeScanner [private]
 

The edge detector.

Definition at line 99 of file RBallSpecialist2.h.

int RBallSpecialist2::threshold [private]
 

The normal threshold.

Definition at line 101 of file RBallSpecialist2.h.

int RBallSpecialist2::minEdgeThreshold [private]
 

The threshold for large balls.

Definition at line 103 of file RBallSpecialist2.h.

Referenced by executePostProcessing(), init(), and RBallSpecialist2().

std::vector<Vector2<int> > RBallSpecialist2::points [private]
 

A buffer for the edge points of a region.

Definition at line 153 of file RBallSpecialist2.h.

int RBallSpecialist2::numberOfEdgePoints [private]
 

The number of edge points.

Definition at line 155 of file RBallSpecialist2.h.

Referenced by calculateCircleByEdges(), calculateLargeCircle(), calculateSmallCircle(), executePostProcessing(), filterBallPoints(), middleEdgePointDist(), and validateEdgePoints().

double RBallSpecialist2::roundness [private]
 

The roundness of the last detected circle.

Definition at line 157 of file RBallSpecialist2.h.

Referenced by addBallPercept(), calculateCircleByEdges(), calculateSmallCircle(), and init().


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