Tekkotsu Homepage
Demos
Overview
Downloads
Dev. Resources
Reference
Credits

AprilTagData.h

Go to the documentation of this file.
00001 #ifndef _APRILTAGDATA_H_
00002 #define _APRILTAGDATA_H_
00003 
00004 #include <vector>
00005 #include <iostream>
00006 
00007 #include "BaseData.h"    // superclass
00008 #include "Point.h"       // Point data member
00009 #include "ShapeFuns.h"
00010 #include "Vision/AprilTags/TagDetection.h"
00011 namespace AprilTags {
00012   class TagFamily;
00013 }
00014 
00015 #include "Sketch.h"
00016 
00017 namespace DualCoding {
00018 
00019   class ShapeRoot;
00020   class SketchSpace;
00021   template<typename T> class Sketch;
00022 
00023   class AprilTagData : public BaseData {
00024   public:
00025 
00026     //! Constructor
00027     AprilTagData(ShapeSpace& _space, const AprilTags::TagDetection& _tagDetection);
00028 
00029     //! Constructor for manually building AprilTag instances in local or world maps
00030     AprilTagData(ShapeSpace& _space, const AprilTags::TagDetection& _tagDetection, 
00031                  const Point &_center, const fmat::Quaternion &_q = fmat::Quaternion());
00032 
00033     //! Copy constructor
00034     AprilTagData(const AprilTagData &other);
00035 
00036     //! Destructor
00037     ~AprilTagData() {};
00038 
00039     static ShapeType_t getStaticType() { return aprilTagDataType; }
00040 
00041     DATASTUFF_H(AprilTagData);
00042   
00043     //! Returns the tag detection represented by this shape
00044     const AprilTags::TagDetection& getTagDetection() const { return tagDetection; }
00045 
00046     //! Centroid. (Virtual in BaseData.)
00047     Point getCentroid() const { return center; } 
00048     void setCentroid(const Point& other) { center.setCoords(other); }
00049   
00050     //! Returns the bounding box of the AprilTag object in the camera reference frame; not the same as getTopLeft() etc.
00051     virtual BoundingBox2D getBoundingBox() const;
00052 
00053     //! Bounding box points with respect to the tag itself, i.e., "top left" is always the same point on the tag, independent of tag orientation
00054     Point getTopLeft() const;
00055     Point getTopRight() const;
00056     Point getBottomLeft() const;
00057     Point getBottomRight() const;
00058 
00059     //! Match AprilTag objects based on their parameters.  (Virtual in BaseData.)
00060     virtual bool isMatchFor(const ShapeRoot& other) const;
00061 
00062     virtual bool isAdmissible() const { return true; }
00063 
00064     virtual bool updateParams(const ShapeRoot& other, bool force=false);
00065 
00066     //! Print information about this shape. (Virtual in BaseData.)
00067     virtual void printParams() const;
00068   
00069     //! Transformations. (Virtual in BaseData.)
00070     void applyTransform(const fmat::Transform& Tmat, const ReferenceFrameType_t newref=unspecified);
00071   
00072     //! Project to ground
00073     virtual void projectToGround(const fmat::Transform& camToBase, const PlaneEquation& groundplane);
00074 
00075     virtual unsigned short getDimension() const { return 2; }
00076   
00077     //! Properties functions.
00078     //@{
00079 
00080     //! The ID number encoded in this AprilTag
00081     int getTagID() const { return tagDetection.id; }
00082 
00083     fmat::Quaternion getQuaternion() const; //! Only works for vertical tags at expected marker height
00084 
00085     int getHammingDistance() const { return tagDetection.hammingDistance; }
00086     //@}
00087     //! Extraction.
00088     static std::vector<Shape<AprilTagData> > extractAprilTags(const Sketch<uchar> &rawY, const AprilTags::TagFamily &tagFamily);
00089 
00090     //! Find a tag with the specified tag ID
00091     static Shape<AprilTagData> findTag(const std::vector<ShapeRoot> &shapevec, int id);
00092   
00093     //! For sorting tags by ID
00094     class TagIDLessThan : public BinaryShapePred<AprilTagData> {
00095     public:
00096       bool operator() (const Shape<AprilTagData> &tag1, const Shape<AprilTagData> &tag2) const;
00097     };
00098 
00099   protected:
00100     Point getBottomLeftImagePoint() const;  //!< Used for determining orientation of vertical AprilTags
00101     Point getBottomRightImagePoint() const;
00102 
00103     //! The tag detection represented by this shape
00104     AprilTags::TagDetection tagDetection;
00105     Point center;
00106     fmat::Quaternion q;
00107     Point bl, br;
00108 
00109   private:
00110     //! Render into a sketch space and return pointer. (Private.)
00111     virtual Sketch<bool>* render() const;
00112     AprilTagData& operator=(const AprilTagData&); //!< don't call
00113   };
00114 
00115 
00116 } // namespace
00117 
00118 #endif

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