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"
00008 #include "Point.h"
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
00027 AprilTagData(ShapeSpace& _space, const AprilTags::TagDetection& _tagDetection);
00028
00029
00030 AprilTagData(ShapeSpace& _space, const AprilTags::TagDetection& _tagDetection,
00031 const Point &_center, const fmat::Quaternion &_q = fmat::Quaternion());
00032
00033
00034 AprilTagData(const AprilTagData &other);
00035
00036
00037 ~AprilTagData() {};
00038
00039 static ShapeType_t getStaticType() { return aprilTagDataType; }
00040
00041 DATASTUFF_H(AprilTagData);
00042
00043
00044 const AprilTags::TagDetection& getTagDetection() const { return tagDetection; }
00045
00046
00047 Point getCentroid() const { return center; }
00048 void setCentroid(const Point& other) { center.setCoords(other); }
00049
00050
00051 virtual BoundingBox2D getBoundingBox() const;
00052
00053
00054 Point getTopLeft() const;
00055 Point getTopRight() const;
00056 Point getBottomLeft() const;
00057 Point getBottomRight() const;
00058
00059
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
00067 virtual void printParams() const;
00068
00069
00070 void applyTransform(const fmat::Transform& Tmat, const ReferenceFrameType_t newref=unspecified);
00071
00072
00073 virtual void projectToGround(const fmat::Transform& camToBase, const PlaneEquation& groundplane);
00074
00075 virtual unsigned short getDimension() const { return 2; }
00076
00077
00078
00079
00080
00081 int getTagID() const { return tagDetection.id; }
00082
00083 fmat::Quaternion getQuaternion() const;
00084
00085 int getHammingDistance() const { return tagDetection.hammingDistance; }
00086
00087
00088 static std::vector<Shape<AprilTagData> > extractAprilTags(const Sketch<uchar> &rawY, const AprilTags::TagFamily &tagFamily);
00089
00090
00091 static Shape<AprilTagData> findTag(const std::vector<ShapeRoot> &shapevec, int id);
00092
00093
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;
00101 Point getBottomRightImagePoint() const;
00102
00103
00104 AprilTags::TagDetection tagDetection;
00105 Point center;
00106 fmat::Quaternion q;
00107 Point bl, br;
00108
00109 private:
00110
00111 virtual Sketch<bool>* render() const;
00112 AprilTagData& operator=(const AprilTagData&);
00113 };
00114
00115
00116 }
00117
00118 #endif