AgentData.h
Go to the documentation of this file.00001
00002 #ifndef _AGENTDATA_H_
00003 #define _AGENTDATA_H_
00004
00005 #include "BaseData.h"
00006 #include "Point.h"
00007 #include "ShapeEllipse.h"
00008 #include "Shared/Measures.h"
00009 #include "ShapeTypes.h"
00010 #include "Shared/RobotInfo.h"
00011 #include "Sketch.h"
00012
00013 namespace DualCoding {
00014
00015 class ShapeRoot;
00016 class SketchSpace;
00017 template<typename T> class Sketch;
00018
00019
00020 class AgentData : public BaseData {
00021 private:
00022 Point center_pt;
00023 AngTwoPi orientation;
00024 int hostAddr;
00025
00026 public:
00027
00028 AgentData(ShapeSpace& _space, const Point &c, AngTwoPi orient=0.f);
00029
00030
00031 AgentData(const AgentData& otherData);
00032
00033 static ShapeType_t getStaticType() { return agentDataType; }
00034
00035
00036
00037
00038
00039 DATASTUFF_H(AgentData);
00040
00041
00042 Point getCentroid() const { return center_pt; }
00043
00044
00045 int getHostAddr() const { return hostAddr; }
00046
00047
00048 void setHostAddr(int addr) { hostAddr = addr; }
00049
00050
00051 BoundingBox2D getBoundingBox() const;
00052
00053
00054 virtual bool isMatchFor(const ShapeRoot& other) const;
00055
00056
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
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);
00074 void setCentroidPt(const Point &otherPt) { center_pt.setCoords(otherPt); }
00075
00076
00077 virtual Sketch<bool>* render() const;
00078
00079 AgentData& operator=(const AgentData&);
00080
00081
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 }
00132
00133 #endif