#include <BoxSpecialist.h>
Inheritance diagram for BoxSpecialist:
Public Types | |
typedef Geometry::Line | Line |
typedef vector< list< RasterSpecialist::LinePair > > | SVector |
Public Member Functions | |
BoxSpecialist (RasterImageProcessor &processor, RasterStrategy &strategy) | |
virtual | ~BoxSpecialist () |
void | invokeOnPostScan (int x, int y) |
void | executePostProcessing () |
void | invokeOnPreScan (int x, int y) |
virtual int | getType () |
virtual void | init () |
Private Member Functions | |
void | createBBox () |
bool | searchGoal (SegmentInfo &goal) |
bool | searchLandmark (SegmentInfo &flag) |
void | fitLandmark (SegmentInfo &flag) |
void | detectFreePartOfGoal () |
void | fusionGoal () |
void | mergeBoxes (SegmentInfo &seg1, SegmentInfo &seg2) |
void | countColors (SegmentInfo &si, list< LinePair > &segment) |
bool | missingData (bool ulc, bool urc, bool brc, bool blc, int i) |
void | calculateAnglesForPoint (const Vector2< double > &point, const CameraMatrix &cameraMatrix, const CameraInfo &cameraInfo, Vector2< double > &angles) |
bool | calculatePointOnField (const double x, const double y, const CameraMatrix &cameraMatrix, const CameraInfo &cameraInfo, Vector2< int > &pointOnField) |
void | createValidities (SegmentInfo &info) |
Private Attributes | |
RasterStrategy * | strategy |
REdgeDetection | edgeScanner |
std::list< LinePair > | lst_pts |
Geometry::Line | horizon |
Geometry::Line | pHorizon |
int | flagThreshold |
int | goalThreshold |
Vector2< int > | left_border |
std::vector< list< LinePair > > | segments_img |
std::vector< SegmentInfo > | infos_img |
std::vector< Vector2< int > > | bottomPoints |
Classes | |
class | Rectangle |
class | SegmentInfo |
Definition at line 27 of file BoxSpecialist.h.
typedef Geometry::Line BoxSpecialist::Line |
Definition at line 74 of file BoxSpecialist.h.
typedef vector<list<RasterSpecialist::LinePair> > BoxSpecialist::SVector |
Definition at line 75 of file BoxSpecialist.h.
BoxSpecialist::BoxSpecialist | ( | RasterImageProcessor & | processor, | |
RasterStrategy & | strategy | |||
) |
Constructor
processor | Image processor interfaces. | |
strategy | A strategy is needed for creation (this will change). |
Definition at line 21 of file BoxSpecialist.cpp.
References InFile::exists(), flagThreshold, getLocation(), goalThreshold, idText, OUTPUT, RasterSpecialist::postScanNeeded, RasterSpecialist::preScanNeeded, strategy, and text.
BoxSpecialist::~BoxSpecialist | ( | ) | [virtual] |
Destructor
Definition at line 46 of file BoxSpecialist.cpp.
void BoxSpecialist::calculateAnglesForPoint | ( | const Vector2< double > & | point, | |
const CameraMatrix & | cameraMatrix, | |||
const CameraInfo & | cameraInfo, | |||
Vector2< double > & | angles | |||
) | [private] |
Definition at line 989 of file BoxSpecialist.cpp.
References CameraInfo::openingAngleWidth, CameraInfo::resolutionHeight, CameraInfo::resolutionWidth, Pose3D::rotation, sqr, Vector3< V >::x, Vector2< V >::x, Vector3< V >::y, Vector2< V >::y, and Vector3< V >::z.
Referenced by fusionGoal(), and searchGoal().
bool BoxSpecialist::calculatePointOnField | ( | const double | x, | |
const double | y, | |||
const CameraMatrix & | cameraMatrix, | |||
const CameraInfo & | cameraInfo, | |||
Vector2< int > & | pointOnField | |||
) | [private] |
Definition at line 1017 of file BoxSpecialist.cpp.
References abs(), int(), CameraInfo::openingAngleHeight, CameraInfo::openingAngleWidth, CameraInfo::resolutionHeight, CameraInfo::resolutionWidth, Pose3D::rotation, Pose3D::translation, Vector2< V >::x, Vector3< V >::x, Vector2< V >::y, Vector3< V >::y, and Vector3< V >::z.
void BoxSpecialist::countColors | ( | SegmentInfo & | si, | |
list< LinePair > & | segment | |||
) | [private] |
Counts the colors of segment si. And stores the result in si.
si | SegmentInfo of the region. | |
segment | List of runs. |
Definition at line 851 of file BoxSpecialist.cpp.
References max, min, pink, BoxSpecialist::SegmentInfo::pink, skyblue, BoxSpecialist::SegmentInfo::skyblue, yellow, and BoxSpecialist::SegmentInfo::yellow.
Referenced by createBBox().
void BoxSpecialist::createBBox | ( | ) | [private] |
Creates the bounding box aligned to the horizon for each region.
Definition at line 63 of file BoxSpecialist.cpp.
References Geometry::Line::base, BoxSpecialist::SegmentInfo::bottomColor, BoxSpecialist::Rectangle::bottomLeft, BoxSpecialist::Rectangle::bottomRight, BoxSpecialist::Rectangle::center, countColors(), createValidities(), Geometry::Line::direction, dist(), RasterSpecialist::getColor(), RasterSpecialist::getDistanceToLine(), Geometry::getIntersectionOfLines(), horizon, infos_img, pHorizon, BoxSpecialist::SegmentInfo::rect, BoxSpecialist::SegmentInfo::segment, segments_img, BoxSpecialist::SegmentInfo::size, BoxSpecialist::SegmentInfo::topColor, BoxSpecialist::Rectangle::upperLeft, BoxSpecialist::Rectangle::upperRight, Vector2< V >::x, and Vector2< V >::y.
Referenced by executePostProcessing().
void BoxSpecialist::createValidities | ( | SegmentInfo & | info | ) | [private] |
Creates the validity values for the different kinds of objects. The result is stored in info.
info | The info represents a region. |
Definition at line 1052 of file BoxSpecialist.cpp.
References info.
Referenced by createBBox().
void BoxSpecialist::detectFreePartOfGoal | ( | ) | [private] |
Detects the free part of the goal and generates a percept. This function is not completed yet.
Definition at line 1108 of file BoxSpecialist.cpp.
References abs(), ObstaclesPercept::angleToFreePartOfGoal, ObstaclesPercept::angleToFreePartOfGoalWasDetermined, bottomPoints, Geometry::calculateAnglesForPoint(), Image::cameraInfo, ImageProcessorInterfaces::cameraMatrix, distance(), ObstaclesPercept::distanceToFreePartOfGoal, Drawings::green, ImageProcessorInterfaces::image, LINE, ImageProcessorInterfaces::obstaclesPercept, ObstaclesPercept::opponentGoal, pi, Drawings::ps_solid, CameraInfo::resolutionHeight, CameraInfo::resolutionWidth, RasterSpecialist::rip, Pose3D::translation, ObstaclesPercept::widthOfFreePartOfGoal, Vector3< V >::x, Vector2< V >::x, Vector2< V >::y, and Vector3< V >::y.
void BoxSpecialist::executePostProcessing | ( | ) | [virtual] |
Executes the detection algorithm.
Reimplemented from RasterSpecialist.
Definition at line 734 of file BoxSpecialist.cpp.
References Geometry::Line::base, Drawings::blue, ImageProcessorInterfaces::cameraMatrix, createBBox(), RasterSpecialist::createSegmentsFromLines2(), Geometry::Line::direction, edgeScanner, LandmarksPercept::estimateOffsetForFlags(), LandmarksPercept::estimateOffsetForGoals(), flagThreshold, RasterImageProcessor::getHorizon(), goalThreshold, Drawings::green, horizon, infos_img, ImageProcessorInterfaces::landmarksPercept, LINE, lst_pts, pHorizon, Drawings::ps_solid, RasterSpecialist::rip, Vector2< V >::rotateLeft(), searchGoal(), searchLandmark(), segments_img, REdgeDetection::threshold, Pose3D::translation, Drawings::white, Vector3< V >::x, Vector3< V >::y, and Drawings::yellow.
Referenced by RDefaultStrategy::postProcessing().
void BoxSpecialist::fitLandmark | ( | SegmentInfo & | flag | ) | [private] |
This function detects the accurate shape of a landmark.
flag | SegmentInfo of a region that was detected as a landmark. |
Definition at line 678 of file BoxSpecialist.cpp.
References abs(), Drawings::black, BoxSpecialist::Rectangle::bottomLeft, BoxSpecialist::Rectangle::center, Geometry::Line::direction, DOT, east, edgeScanner, Drawings::green, horizon, north, pHorizon, BoxSpecialist::SegmentInfo::rect, Drawings::red, REdgeDetection::scan(), REdgeDetection::skip(), south, BoxSpecialist::Rectangle::upperLeft, west, Drawings::white, Vector2< V >::x, and Vector2< V >::y.
void BoxSpecialist::fusionGoal | ( | ) | [private] |
Fusions the regions that belong to the same goal. This function is not completed yet. But the algorithm is tested.
Definition at line 885 of file BoxSpecialist.cpp.
References abs(), LandmarksPercept::addGoal(), ConditionalBoundary::addX(), ConditionalBoundary::addY(), b, Player::blue, BoxSpecialist::SegmentInfo::bottomColor, BoxSpecialist::Rectangle::bottomLeft, BoxSpecialist::Rectangle::bottomRight, calculateAnglesForPoint(), Image::cameraInfo, ImageProcessorInterfaces::cameraMatrix, BoxSpecialist::Rectangle::center, Geometry::getDistanceToLine(), getPlayer(), Player::getTeamColor(), BoxSpecialist::SegmentInfo::goalValidity, horizon, ImageProcessorInterfaces::image, RasterSpecialist::imageWidth, infos_img, ImageProcessorInterfaces::landmarksPercept, LINE, mergeBoxes(), missingData(), BoxSpecialist::SegmentInfo::pink, Drawings::ps_solid, BoxSpecialist::SegmentInfo::rect, RasterSpecialist::rip, searchGoal(), skyblue, BoxSpecialist::SegmentInfo::skyblue, BoxSpecialist::Rectangle::upperLeft, BoxSpecialist::Rectangle::upperRight, Drawings::white, Vector2< V >::x, Vector2< V >::y, yellow, and BoxSpecialist::SegmentInfo::yellow.
int BoxSpecialist::getType | ( | ) | [virtual] |
Getter for member type.
Implements RasterSpecialist.
Definition at line 49 of file BoxSpecialist.cpp.
References __RBoxSpecialist.
void BoxSpecialist::init | ( | ) | [virtual] |
Initializes the specialist.
Implements RasterSpecialist.
Definition at line 53 of file BoxSpecialist.cpp.
References bottomPoints, edgeScanner, infos_img, lst_pts, segments_img, and REdgeDetection::threshold.
Referenced by RDefaultStrategy::init().
void BoxSpecialist::invokeOnPostScan | ( | int | x, | |
int | y | |||
) | [virtual] |
Invokes the specialist in the second scan stage at position (x,y) (this member should be replaced later).
x | The x coordinate. | |
y | The y coordinate. |
Reimplemented from RasterSpecialist.
Definition at line 729 of file BoxSpecialist.cpp.
References bottomPoints.
Referenced by RDefaultStrategy::postScan().
void BoxSpecialist::invokeOnPreScan | ( | int | x, | |
int | y | |||
) | [virtual] |
Invokes the specialist in the first scan stage at position (x,y) (this member should be replaced later).
x | The x coordinate. | |
y | The y coordinate. |
Reimplemented from RasterSpecialist.
Definition at line 165 of file BoxSpecialist.cpp.
References edgeScanner, RasterSpecialist::getColor(), RasterStrategy::insideBox, left_border, LINE, lst_pts, Drawings::ps_solid, Drawings::red, REdgeDetection::scanEast(), REdgeDetection::scanWest(), and strategy.
Referenced by RDefaultStrategy::checkBox(), and RDefaultStrategy::preScan().
void BoxSpecialist::mergeBoxes | ( | SegmentInfo & | seg1, | |
SegmentInfo & | seg2 | |||
) | [private] |
Merges two regions. The result is stored in seg1.
seg1 | The first region. | |
seg2 | The second region. |
Definition at line 809 of file BoxSpecialist.cpp.
References Geometry::Line::base, BoxSpecialist::Rectangle::bottomLeft, BoxSpecialist::Rectangle::bottomRight, BoxSpecialist::Rectangle::center, Geometry::Line::direction, Geometry::getDistanceToLine(), Geometry::getIntersectionOfLines(), horizon, pHorizon, BoxSpecialist::SegmentInfo::pink, BoxSpecialist::SegmentInfo::rect, BoxSpecialist::SegmentInfo::size, BoxSpecialist::SegmentInfo::skyblue, BoxSpecialist::Rectangle::upperLeft, BoxSpecialist::Rectangle::upperRight, and BoxSpecialist::SegmentInfo::yellow.
Referenced by fusionGoal().
bool BoxSpecialist::missingData | ( | bool | ulc, | |
bool | urc, | |||
bool | brc, | |||
bool | blc, | |||
int | i | |||
) | [inline, private] |
A small test for goals.
Definition at line 190 of file BoxSpecialist.cpp.
References segments_img.
Referenced by fusionGoal().
bool BoxSpecialist::searchGoal | ( | SegmentInfo & | goal | ) | [private] |
The goal detection algorithm. If a goal was found, a percept will be gemerated.
goal | SegmentInfo of a region that might be a goal. |
Definition at line 197 of file BoxSpecialist.cpp.
References abs(), Vector2< V >::abs(), LandmarksPercept::addGoal(), ConditionalBoundary::addX(), ConditionalBoundary::addY(), b, Geometry::Line::base, Drawings::blue, Player::blue, BoxSpecialist::Rectangle::bottomLeft, BoxSpecialist::Rectangle::bottomRight, calculateAnglesForPoint(), Image::cameraInfo, ImageProcessorInterfaces::cameraMatrix, BoxSpecialist::Rectangle::center, Geometry::Line::direction, DOT, east, edgeScanner, RasterSpecialist::getDistanceToLine(), Geometry::getDistanceToLine(), Geometry::getIntersectionOfLines(), getPlayer(), Player::getTeamColor(), BoxSpecialist::SegmentInfo::goalValidity, horizon, ImageProcessorInterfaces::image, RasterSpecialist::imageWidth, ImageProcessorInterfaces::landmarksPercept, LINE, north, pHorizon, BoxSpecialist::SegmentInfo::pink, Drawings::ps_solid, BoxSpecialist::SegmentInfo::rect, Drawings::red, RasterSpecialist::rip, REdgeDetection::scan(), skyblue, BoxSpecialist::SegmentInfo::skyblue, south, BoxSpecialist::Rectangle::upperLeft, BoxSpecialist::Rectangle::upperRight, west, Drawings::white, Vector2< V >::x, Vector2< V >::y, yellow, and BoxSpecialist::SegmentInfo::yellow.
Referenced by executePostProcessing(), and fusionGoal().
bool BoxSpecialist::searchLandmark | ( | SegmentInfo & | flag | ) | [private] |
The detection algorithm for landmarks. If one is found a percept will be generated.
flag | SegmentInfo of a region that might be a landmark. |
Definition at line 469 of file BoxSpecialist.cpp.
References Vector2< V >::abs(), abs(), RasterImageProcessor::addFlag(), Drawings::black, Drawings::blue, BoxSpecialist::Rectangle::bottomLeft, BoxSpecialist::Rectangle::bottomRight, BoxSpecialist::Rectangle::center, REdgeDetection::colorScan(), Geometry::Line::direction, DOT, east, edgeScanner, Drawings::green, horizon, noColor, north, Flag::numberOfFlagTypes, pHorizon, pink, BoxSpecialist::SegmentInfo::pink, Flag::pinkAboveSkyblue, Flag::pinkAboveYellow, BoxSpecialist::SegmentInfo::rect, Drawings::red, RasterSpecialist::rip, RasterSpecialist::scan(), REdgeDetection::scan(), REdgeDetection::setDirection(), REdgeDetection::skip(), skyblue, BoxSpecialist::SegmentInfo::skyblue, Flag::skyblueAbovePink, south, BoxSpecialist::Rectangle::upperLeft, BoxSpecialist::Rectangle::upperRight, west, Drawings::white, Vector2< V >::x, Vector2< V >::y, yellow, BoxSpecialist::SegmentInfo::yellow, and Flag::yellowAbovePink.
Referenced by executePostProcessing().
std::vector<Vector2<int> > BoxSpecialist::bottomPoints [private] |
The bottomPoints of the goal (edges from green to yellow or skyblue).
Definition at line 126 of file BoxSpecialist.h.
Referenced by detectFreePartOfGoal(), init(), and invokeOnPostScan().
REdgeDetection BoxSpecialist::edgeScanner [private] |
The edge detector.
Definition at line 108 of file BoxSpecialist.h.
Referenced by executePostProcessing(), fitLandmark(), init(), invokeOnPreScan(), searchGoal(), and searchLandmark().
int BoxSpecialist::flagThreshold [private] |
The threshold for edge-scans of the landmark detection.
Definition at line 116 of file BoxSpecialist.h.
Referenced by BoxSpecialist(), and executePostProcessing().
int BoxSpecialist::goalThreshold [private] |
The threshold for edge-scans of the goal detection.
Definition at line 118 of file BoxSpecialist.h.
Referenced by BoxSpecialist(), and executePostProcessing().
Geometry::Line BoxSpecialist::horizon [private] |
The calculated horizon.
Definition at line 112 of file BoxSpecialist.h.
Referenced by createBBox(), executePostProcessing(), fitLandmark(), fusionGoal(), mergeBoxes(), searchGoal(), and searchLandmark().
std::vector<SegmentInfo> BoxSpecialist::infos_img [private] |
The calculated informations about the segments.
Definition at line 124 of file BoxSpecialist.h.
Referenced by createBBox(), executePostProcessing(), fusionGoal(), and init().
Vector2<int> BoxSpecialist::left_border [private] |
A temporary variable.
Definition at line 120 of file BoxSpecialist.h.
Referenced by invokeOnPreScan().
std::list<LinePair> BoxSpecialist::lst_pts [private] |
List of LinePairs. The input data of the detection algorithm.
Definition at line 110 of file BoxSpecialist.h.
Referenced by executePostProcessing(), init(), and invokeOnPreScan().
Geometry::Line BoxSpecialist::pHorizon [private] |
The calculated perpendicular to the horizon.
Definition at line 114 of file BoxSpecialist.h.
Referenced by createBBox(), executePostProcessing(), fitLandmark(), mergeBoxes(), searchGoal(), and searchLandmark().
std::vector<list<LinePair> > BoxSpecialist::segments_img [private] |
The clustered runs.
Definition at line 122 of file BoxSpecialist.h.
Referenced by createBBox(), executePostProcessing(), init(), and missingData().
RasterStrategy* BoxSpecialist::strategy [private] |
The strategy.
Definition at line 106 of file BoxSpecialist.h.
Referenced by BoxSpecialist(), and invokeOnPreScan().