Tekkotsu Homepage
Demos
Overview
Downloads
Dev. Resources
Reference
Credits

TargetData.h

Go to the documentation of this file.
00001 //-*-c++-*-
00002 #ifndef _TARGETDATA_H_
00003 #define _TARGETDATA_H_
00004 
00005 #include "BaseData.h"    // superclass
00006 #include "LineData.h"
00007 #include "Point.h"       // Point data member
00008 #include "EndPoint.h"    // EndPoint data member
00009 #include "ShapeTypes.h"  // TargetDataType
00010 
00011 namespace DualCoding {
00012 
00013 class ShapeRoot;
00014 class SketchSpace;
00015 template<typename T> class Sketch;
00016 
00017 class TargetData : public BaseData {
00018 protected:
00019   LineData frontLine, backLine;
00020   bool frontValid, backValid;
00021   EndPoint frontIntersect, backIntersect;
00022   AngSignPi orientation;
00023   float length, width, height;
00024   
00025 public:
00026   //! Constructor
00027   TargetData(ShapeSpace& _space, const EndPoint &_frontLeftPt, const EndPoint &_frontRightPt, const EndPoint &_backLeftPt, const EndPoint &_backRightPt, const EndPoint &_frontIntersect, const EndPoint &_backIntersect, const float _height);
00028 
00029   //! Copy constructor
00030   TargetData(const TargetData& other)
00031     : BaseData(other),
00032       frontLine(other.frontLine), backLine(other.backLine),
00033       frontValid(other.frontValid), backValid(other.backValid),
00034       frontIntersect(other.frontIntersect), backIntersect(other.backIntersect),
00035       orientation(other.orientation), length(other.length), width(other.width), height(other.height) {}
00036 
00037   static ShapeType_t getStaticType() { return targetDataType; }
00038 
00039   DATASTUFF_H(TargetData);
00040   
00041   //! Centroid. (Virtual in BaseData.)
00042   Point getFrontCentroid() const { return frontValid ? frontLine.getCentroid() : backLine.getCentroid(); }
00043   Point getBackCentroid() const { return backValid ? backLine.getCentroid() : frontLine.getCentroid(); }  
00044   Point getCentroid() const { return (frontValid && backValid) ? (frontLine.getCentroid() + backLine.getCentroid()) / 2: getFrontCentroid(); }
00045   
00046   BoundingBox2D getBoundingBox() const;
00047 
00048   //! Match points based on their parameters.  (Virtual in BaseData.)
00049   virtual bool isMatchFor(const ShapeRoot& other) const;
00050   bool isMatchFor(const TargetData& other_target) const;
00051 
00052   //! minimum length of a target
00053   virtual bool isAdmissible() const { return length > 10.0; }
00054 
00055   //! updates orientation and length from feature points
00056   void update_derived_properties();
00057   
00058   virtual bool updateParams(const ShapeRoot& other, bool force=false);
00059 
00060   virtual void mergeWith(const ShapeRoot& other);
00061 
00062   //! Print information about this shape. (Virtual in BaseData.)
00063   virtual void printParams() const;
00064   
00065   //! Transformations. (Virtual in BaseData.)
00066   void applyTransform(const fmat::Transform& Tmat, const ReferenceFrameType_t newref=unspecified);
00067   
00068   //! Project the Target onto the target plane (ground plane lifted up by height)
00069   virtual void projectToGround(const fmat::Transform& camToBase, const PlaneEquation& groundplane);
00070 
00071   virtual unsigned short getDimension() const { return 3; }
00072 
00073   EndPoint& getFrontLeftPt() { return frontLine.end1Pt(); }
00074   EndPoint& getFrontRightPt() { return frontLine.end2Pt(); }
00075   const EndPoint& getFrontLeftPt() const { return frontLine.end1Pt(); }
00076   const EndPoint& getFrontRightPt() const { return frontLine.end2Pt(); }
00077   
00078   EndPoint& getBackLeftPt() { return backLine.end1Pt(); }
00079   EndPoint& getBackRightPt() { return backLine.end2Pt(); }
00080   const EndPoint& getBackLeftPt() const { return backLine.end1Pt(); }
00081   const EndPoint& getBackRightPt() const { return backLine.end2Pt(); }
00082   
00083   EndPoint &getFrontIntersect() { return frontIntersect; }
00084   EndPoint &getBackIntersect() { return backIntersect; }
00085   const EndPoint &getFrontIntersect() const { return frontIntersect; }
00086   const EndPoint &getBackIntersect() const { return backIntersect; }
00087   
00088   bool isFrontValid() const { return frontValid; }
00089   bool isBackValid() const { return backValid; }
00090   
00091   AngSignPi getOrientation() const { return orientation; }
00092   float getLength() const { return length; }
00093   float getWidth()  const { return width; }
00094   float getHeight() const { return height; }
00095   
00096   TargetData& operator=(const TargetData&);
00097   
00098   float perpendicularDistanceFrom(Point point);
00099   
00100   static Shape<TargetData> extractLineTarget(std::string frontColor = "yellow", std::string backColor = "pink", std::string rightColor = "blue", std::string occluderColor = "orange", const float height = 90.0f);
00101   static Shape<TargetData> extractLineTarget(Sketch<bool>& frontSketch, Sketch<bool>& backSketch, Sketch<bool>& rightSketch, Sketch<bool>& occluderSketch, const float height = 90.0f);
00102   static Shape<TargetData> extractLineTarget(Shape<LineData>& camFrontLine, Shape<LineData>& camBackLine, Shape<LineData>& camRightLine, rgb color, const float height = 90.0f);
00103   
00104 private:
00105   //! Render into a sketch space and return reference. (Private.)
00106   Sketch<bool>* render() const;
00107   //@}
00108 
00109 };
00110 
00111 } // namespace
00112 
00113 #endif
00114 

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