Tekkotsu Homepage
Demos
Overview
Downloads
Dev. Resources
Reference
Credits

MarkerData.h

Go to the documentation of this file.
00001 //-*-c++-*-
00002 #ifndef _MARKERDATA_H_
00003 #define _MARKERDATA_H_
00004 
00005 #include <vector>
00006 #include <set>
00007 #include <map>
00008 #include <iostream>
00009 #include <string>
00010 
00011 #include "Shared/fmatSpatial.h"
00012 
00013 #include "BaseData.h"      // superclass
00014 #include "Point.h"         // Point data member
00015 #include "SketchTypes.h"   // uchar
00016 
00017 namespace DualCoding {
00018 
00019   class ShapeRoot;
00020   template<typename T> class Sketch;
00021 
00022   class MarkerData;
00023   class MapBuilderRequest;
00024 
00025   typedef std::string MarkerType_t;
00026   typedef std::vector<Shape<MarkerData> > (*MarkerExtractFn_t)(const Sketch<uchar>&, const MapBuilderRequest&);
00027 
00028   //! Marker shapes, described by a single point in space
00029   class MarkerData : public BaseData {
00030   public:
00031     //! center (centroid) of marker in coordinate frame.  In image frame this is abused to store (pixel_x,pixel_y,distance).
00032     Point center;
00033     //! The type of marker this is
00034     MarkerType_t typeOfMarker;
00035 
00036     static const MarkerType_t unknownMarkerType;
00037 
00038   public:
00039     //! Constructor
00040     MarkerData(ShapeSpace& _space, const Point& center, const rgb rgbvalue=rgb());
00041 
00042     static ShapeType_t getStaticType() { return markerDataType; }
00043     
00044     MarkerType_t getMarkerType() const { return typeOfMarker; }
00045 
00046     DATASTUFF_H(MarkerData);
00047     
00048     friend class Shape<MarkerData>;
00049     
00050     //! return the centroid of the shape in point format
00051     virtual Point getCentroid() const;
00052     
00053     //! Print information about this shape.
00054     virtual void printParams() const;
00055     
00056     //! Transformations. (Virtual in BaseData.)
00057     virtual void applyTransform(const fmat::Transform& Tmat, const ReferenceFrameType_t newref=unspecified);
00058     
00059     //! Project to ground
00060     virtual void projectToGround(const fmat::Transform& camToBase,
00061          const PlaneEquation& groundplane);
00062     
00063     //! Update derived properties
00064     virtual void update_derived_properties();
00065     
00066     //! Match blobs based on their parameters.  (Virtual in BaseData.)
00067     virtual bool isMatchFor(const ShapeRoot& other) const;
00068     
00069     //! Update parameters given matching shape (for merging in mapping)
00070     virtual bool updateParams(const ShapeRoot& other, bool forceUpdate=false);
00071     
00072     //! Test for marker with matching features.
00073     /*!  Unlike isMatchFor, does not consider positions, should just compare things like colors or
00074          other marker-specific features.
00075       */
00076     virtual bool isMatchingMarker(const Shape<MarkerData>& other) const;
00077     
00078     virtual bool localizeByCamera() const {return true;}
00079 
00080     virtual unsigned short getDimension() const { return 3; }
00081 
00082     //! Return the string description for this marker (used to display marker specific information)
00083     virtual std::string getMarkerDescription() const;
00084 
00085     //! Get the name for a given marker type
00086     static std::string getMarkerTypeName(MarkerType_t type);
00087 
00088     // Marker dispatch stuff
00089     static MarkerType_t registerMarkerType(std::string markerTypeName, MarkerExtractFn_t extractor);
00090 
00091     //! Extract markers of @a type from @a sketch
00092     static std::vector<Shape<MarkerData> > extractMarkers(const Sketch<uchar> &sketch, MarkerType_t type, const MapBuilderRequest &req);
00093 
00094     //! Extract markers of all registered types from @a sketch
00095     static std::vector<Shape<MarkerData> > extractMarkers(const Sketch<uchar> &sketch, const MapBuilderRequest &req);
00096 
00097     //! Set the z-coordinate (distance from the camera) for a pixel, assuming we know the object's height above the ground plane
00098     static void calculateCameraDistance(Point &p, const float height);
00099 
00100     //! Return set of all known marker types; used for general-purpose localization code
00101     static const std::set<MarkerType_t> allMarkerTypes();
00102 
00103   private:
00104     //! Map for marker extraction dispatch  
00105     static std::map<MarkerType_t, MarkerExtractFn_t>& getExtractorMap();
00106 
00107     //! Render into a sketch space and return reference. (Private.)
00108     virtual Sketch<bool>* render() const;
00109     
00110     MarkerData& operator=(const MarkerData&); //!< don't call
00111   };
00112 
00113 } // namespace
00114 
00115 #endif // MARKERDATA_H_

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