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

# Modules/ImageProcessor/VLCImageProcessor/VLCRobotSpecialist.h

Go to the documentation of this file.

    00001 /**
    00002 * @file VLCRobotSpecialist.h
    00003 *
    00004 * This file contains a class for Image Processing.
    00005 *
    00006 * @author Tobias Wegner
    00007 */
    00008
    00009 #ifndef __VLCRobotSpecialist_h_
    00010 #define __VLCRobotSpecialist_h_
    00011
    00012 #include "VLCTypes.h"
    00013
    00014 #ifdef oo7
    00015
    00016 #define RS_DEBUG
    00017
    00018 //#define RS_DEBUG_SHOW_RUNS
    00019 #define RS_DEBUG_FEET
    00020
    00021 //#define RS_DEBUG_CONSOLE
    00022 //#define RS_DEBUG_SHOW_CLUSTER_INFO
    00023 #define RS_DEBUG_SHOW_COLORSPACE_INFO
    00024 #define RS_DEBUG_SHOW_CONNECTIONS
    00025 //#define RS_DEBUG_SHOW_START_RUN
    00026 //#define RS_DEBUG_SHOW_GREENCHANGE
    00027 #define RS_DEBUG_SHOW_BOUNDINGBOX
    00028 //#define RS_DEBUG_SHOW_PERCEPT
    00029 //#define RS_GROW_BB
    00030 //#define RS_DEBUG_DRAW_RADIAL_SCANLINES_ONLY
    00031 #endif
    00032
    00033 #include "Tools/Debugging/DebugDrawings.h"
    00034 #include "Tools/Math/Geometry.h"
    00035 #include "Tools/List.h"
    00036 #include "Tools/Debugging/DebugImages.h"
    00037 #include "Representations/Perception/ColorTable.h"
    00038 #include "Representations/Perception/Image.h"
    00039 #include "Representations/Perception/CameraMatrix.h"
    00040 #include "Representations/Perception/BallPercept.h"
    00041 #include "Representations/Perception/LinesPercept.h"
    00042 #include "Representations/Perception/PlayersPercept.h"
    00043 #include "Representations/Perception/MSHSinglePlayerPercept.h"
    00044 #include "Modules/ImageProcessor/ImageProcessorTools/ColorCorrector.h"
    00045 #include "Modules/ImageProcessor/ImageProcessorTools/BresenhamLineScan.h"
    00046 #include "Modules/ImageProcessor/ImageProcessorTools/ImageProcessorUtilityClasses.h"
    00047 #include "VLCImageProcessorTools.h"
    00048 //#include "Tools/Math/Common.h"
    00049
    00050 #include "VLCClustering.h"
    00051
    00052 #include "VLCColorSpace.h"
    00053
    00054
    00055 #define RS_FOOT_THRESHOLD     8
    00056 #define RS_FOOT_GRADIENT      5
    00057 #define RS_NUM_SCAN_LINES     30.0
    00058 //#define RS_FIXED_NO_GREEN_THRESHOLD
    00059 #define RS_NO_GREEN_PIXEL_THRESHOLD 5
    00060 #define RS_NGP_TH_START       10
    00061 #define RS_NGP_TH_STOP        2
    00062
    00063 #define RS_NUM_CANDIDATES     256
    00064
    00065
    00066 struct RobotCandidate
    00067 {
    00068   Vector2<int>  footPoint;
    00069   Vector2<int>  candidateStart;
    00070   Vector2<int>  candidateStop;
    00071   colorClass    color;
    00072   int       lineID;
    00073 };
    00074
    00075 struct CandidateCluster
    00076 {
    00077   int startPosition;
    00078   int stopPosition;
    00079 };
    00080
    00081 /**
    00082 The RobotSpecialist finds other robots in an image.
    00083 */
    00084 class VLCRobotSpecialist
    00085 {
    00086 public:
    00087   VLCRobotSpecialist(const ColorCorrector& colorCorrector_, const Image& image_, const ImageInfo& imageInfo_, const ColorTable& colorTable_, const CameraMatrix& cameraMatrix_, const CameraMatrix& prevCameraMatrix_, LinesPercept& linesPercept_, PlayersPercept &playersPercept_, const RobotPose& robotPose_, const List<GreenChangeEvent>& greenChangeEvents_);
    00088
    00089   /**
    00090   * Resets inner states, should be called every new frame
    00091   */
    00092   void reset
    00093   (
    00094   );
    00095
    00096   /**
    00097   * Generates scanlines for further scanning
    00098   */
    00099   void scan
    00100   (
    00101   );
    00102
    00103   /**
    00104   * Scans perpendicular to horizon
    00105   */
    00106   void scan(
    00107     Vector2<int> startPoint
    00108   );
    00109
    00110   /**
    00111   * Searches for other robots in the image
    00112   */
    00113   void scan (
    00114     Vector2<int> startPoint,
    00115     Vector2<int> endPoint
    00116   );
    00117
    00118   /**
    00119   * Adds candidate to list
    00120   */
    00121   void addCandidate (
    00122     RobotCandidate  candidate
    00123   );
    00124
    00125   bool findNearestFootPoint (
    00126     Vector2<int>    &footPoint
    00127   );
    00128
    00129   /**
    00130   * Generates PlayersPercepts from candidates
    00131   */
    00132   void clusterCandidates (
    00133   )
    00134   {
    00135     clusterCandidates (red);
    00136     clusterCandidates (blue);
    00137   };
    00138
    00139   void clusterCandidates (
    00140     colorClass  color
    00141   );
    00142
    00143   /**
    00144   * Generates a percept for each cluster
    00145   */
    00146   void generatePercept (
    00147     CandidateCluster  cluster
    00148   );
    00149
    00150   /**
    00151   * Scans for <colorClass> pixels between both points
    00152   */
    00153   int noColorPixelsBetween (
    00154     Vector2<int>,
    00155     Vector2<int>,
    00156     colorClass
    00157   );
    00158
    00159   ColorSpace generateColorspace (
    00160     Vector2<int>,
    00161     Vector2<int>
    00162   );
    00163
    00164   unsigned int filterPercepts (
    00165     ColorSpace colorSpace,
    00166     colorClass candidateColor
    00167   );
    00168
    00169   void addPercept (
    00170     PerceptInfo &perceptInfo
    00171   );
    00172
    00173   /**
    00174   * Debugfunctions
    00175   */
    00176   void dbg_PrintGreenchanges (
    00177   );
    00178
    00179 private:
    00180   const ColorCorrector& colorCorrector;
    00181
    00182   const Image& image;
    00183   const ImageInfo& imageInfo;
    00184   const ColorTable& colorTable;
    00185   const CameraMatrix& cameraMatrix;
    00186   const CameraMatrix& prevCameraMatrix;
    00187   const RobotPose&  robotPose;
    00188   const List<GreenChangeEvent>& greenChangeEvents;
    00189
    00190   LinesPercept& linesPercept;
    00191   PlayersPercept& playersPercept;
    00192
    00193   //footpoints
    00194   RobotCandidate  candidates[RS_NUM_CANDIDATES];
    00195   unsigned char topIndex, bottomIndex;
    00196
    00197   List<GreenChangeEvent>::Pos footIterator;
    00198
    00199   //needed for imp copied stuff
    00200   int noRedCount, noBlueCount;
    00201   Vector2<int> lastRed, firstRed, closestRed, lastBlue, firstBlue, closestBlue;
    00202
    00203   //for geometry
    00204   int distanceOnField (Vector2<int>, Vector2<int>, CameraMatrix, CameraInfo);
    00205   int generateBoundings (
    00206     CandidateCluster  cluster,
    00207     VLCRectangle    &body,
    00208     VLCRectangle    &foot,
    00209     Vector2<int>    &footAVG
    00210   );
    00211 };
    00212
    00213 #endif// __BallSpecialist_h_