Tekkotsu Homepage
Demos
Overview
Downloads
Dev. Resources
Reference
Credits

AgentData.h

Go to the documentation of this file.
00001 //-*-c++-*-
00002 #ifndef _AGENTDATA_H_
00003 #define _AGENTDATA_H_
00004 
00005 #include "BaseData.h"    // superclass
00006 #include "Point.h"       // Point data member
00007 #include "ShapeEllipse.h"
00008 #include "Shared/Measures.h"    // coordinate_t; AngPi data member
00009 #include "ShapeTypes.h"  // agentDataType
00010 #include "Shared/RobotInfo.h" // bounding box stuff
00011 #include "Sketch.h"
00012 
00013 namespace DualCoding {
00014 
00015 class ShapeRoot;
00016 class SketchSpace;
00017 template<typename T> class Sketch;
00018 
00019 //! Representation of the robot on the world map
00020 class AgentData : public BaseData {
00021 private:
00022   Point center_pt;
00023   AngTwoPi orientation;
00024   int hostAddr;
00025 
00026 public:
00027   //! Constructor
00028   AgentData(ShapeSpace& _space, const Point &c, AngTwoPi orient=0.f);
00029   
00030   //! Copy constructor
00031   AgentData(const AgentData& otherData);
00032   
00033   static ShapeType_t getStaticType() { return agentDataType; }
00034 
00035   // =========================================
00036   // BEGIN FUNCTIONS
00037   // =========================================
00038   
00039   DATASTUFF_H(AgentData);
00040   
00041   //! Centroid. (Virtual in BaseData.)
00042   Point getCentroid() const { return center_pt; }
00043   
00044   //! Returns the agent's IP address
00045   int getHostAddr() const { return hostAddr; }
00046 
00047   //! Sets the agent's IP address
00048   void setHostAddr(int addr) { hostAddr = addr; }
00049 
00050   //! Returns the bounding box of the agent
00051   BoundingBox2D getBoundingBox() const;
00052 
00053   //! Match agents based on their parameters.  (Virtual in BaseData.)
00054   virtual bool isMatchFor(const ShapeRoot& other) const;
00055   
00056   //! Print information about this shape. (Virtual in BaseData.)
00057   virtual void printParams() const;
00058   
00059   virtual bool updateParams(const ShapeRoot& other, bool force=false);
00060   
00061   virtual void projectToGround(const fmat::Transform& camToBase,
00062              const PlaneEquation& groundplane);
00063   
00064   //! Transformations. (Virtual in BaseData.)
00065   virtual void applyTransform(const fmat::Transform& Tmat, const ReferenceFrameType_t newref=unspecified);  
00066 
00067   virtual unsigned short getDimension() const { return 3; }  
00068 
00069   AngTwoPi getOrientation() const { return orientation; }
00070   fmat::Column<3> getBoundingBoxOffset() const {return AgentBoundingBoxBaseFrameOffset;}
00071   fmat::Column<3> getBoundingBoxHalfDims() const {return AgentBoundingBoxHalfDims;}
00072   
00073   void setOrientation(AngTwoPi _orientation); //!< Don't call this; use MapBuilder::setAgent()
00074   void setCentroidPt(const Point &otherPt) { center_pt.setCoords(otherPt); }  //!< Don't call this; use MapBuilder::setAgent()
00075 
00076   //! Render into a sketch space and return reference.
00077   virtual Sketch<bool>* render() const;
00078 
00079   AgentData& operator=(const AgentData&); //!< don't call
00080   
00081   //! Extraction
00082 
00083   enum RobotSide {
00084     FRONT,
00085     BACK,
00086     LEFT,
00087     RIGHT
00088   };
00089 
00090   struct ColorIdTarget {
00091     int id;
00092     int y_low;
00093     int y_high;
00094     int u_0;
00095         float u_slope;
00096     int v_0;
00097         float v_slope;
00098   };
00099 
00100   static const int NUM_COLOR_IDS = 4;
00101   static ColorIdTarget color_ids[NUM_COLOR_IDS];
00102   static const char *agent_names[NUM_COLOR_IDS];
00103 
00104   static int getColorIdMatch(yuv pixelColor);
00105   static int getIdFromCenter(const Sketch<yuv> &cam_frame, const Point &a, const Point &b, const Point &c);
00106   static int getIdFromCorner(const Sketch<yuv> &cam_frame, const Point &vert_a, const Point &vert_b, const Point &loner);
00107 
00108   static bool inline compareCircleSize(const Shape<EllipseData> &a, const Shape<EllipseData> &b) {
00109     float radius_diff = a->getSemimajor() - b->getSemimajor();
00110     return fabs(radius_diff) < 3;
00111   }
00112 
00113   static bool inline compareCircleDist(const Point &a, const Point &b) {
00114     const int DISTANCE_LIMIT = 200;
00115     return fabs(a.coordX() - b.coordX()) < DISTANCE_LIMIT;
00116   }
00117 
00118   static bool circlesVerticallyAligned(const Shape<EllipseData> &a, const Shape<EllipseData> &b);
00119   static bool circlesHorizontallyAligned(const Shape<EllipseData> &a, const Shape<EllipseData> &b);
00120 
00121   static void findCirclesManual(const Sketch<uchar> &camFrame, std::vector<int> &neighbor_density,
00122                                 std::vector<Shape<EllipseData> > &agentIdCircles);
00123   static void findAgentsBelt(const Sketch<yuv> &camFrameYUV, const std::vector<int> &neighbor_density,
00124                              const std::vector<Shape<EllipseData> > &agentIdCircles);
00125   static void filterAgentOverlap();
00126   static void extractAgents(const Sketch<uchar> &camFrame, const Sketch<yuv> &camFrameYUV, const std::set<color_index> &objcolors);
00127 
00128 
00129 };
00130 
00131 } // namespace
00132 
00133 #endif

DualCoding 5.1CVS
Generated Mon May 9 04:56:25 2016 by Doxygen 1.6.3