Tekkotsu Homepage
Demos
Overview
Downloads
Dev. Resources
Reference
Credits

Quad.h

Go to the documentation of this file.
00001 #ifndef QUAD_H
00002 #define QUAD_H
00003 
00004 #define QUAD_INTERPOLATE 1  // borrowed from Michael Kaess' AprilTags library
00005 
00006 #include <utility>
00007 #include <vector>
00008 #include <iostream>
00009 
00010 #include "Shared/fmat.h"
00011 #include "Homography33.h"
00012 
00013 namespace AprilTags {
00014 
00015 class FloatImage;
00016 class Segment;
00017 
00018 using std::min;
00019 using std::max;
00020 
00021 //! Represents four segments that form a loop, and might be a tag.
00022 class Quad {
00023 public:
00024   static const int minimumEdgeLength = 6; //!< Minimum size of a tag (in pixels) as measured along edges and diagonals
00025   static float const maxQuadAspectRatio; //!< Early pruning of quads with insane ratios.
00026 
00027   //! Constructor
00028   /*! (x,y) are the optical center of the camera, which is
00029    *   needed to correctly compute the homography. */
00030   Quad(const std::vector< std::pair<float,float> >& p, const std::pair<float,float>& opticalCenter);
00031 
00032   //! Interpolate given that the lower left corner of the lower left cell is at (-1,-1) and the upper right corner of the upper right cell is at (1,1).
00033   std::pair<float,float> interpolate(float x, float y);
00034 
00035   //! Same as interpolate, except that the coordinates are interpreted between 0 and 1, instead of -1 and 1.
00036   inline std::pair<float,float> interpolate01(float x, float y) { return interpolate(2*x-1, 2*y-1); }
00037 
00038   //! Points for the quad (in pixel coordinates), in counter clockwise order. These points are the intersections of segments.
00039   std::vector< std::pair<float,float> > quadPoints;
00040 
00041   //! Segments composing this quad
00042   std::vector<Segment*> segments;
00043 
00044   //! Total length (in pixels) of the actual perimeter observed for the quad.
00045   /*! This is in contrast to the geometric perimeter, some of which
00046    *  may not have been directly observed but rather inferred by
00047    *  intersecting segments. Quads with more observed perimeter are
00048    *  preferred over others. */
00049   float observedPerimeter;
00050 
00051   //! Given that the whole quad spans from (0,0) to (1,1) in "quad space", compute the pixel coordinates for a given point within that quad.
00052   /*!  Note that for most of the Quad's existence, we will not know the correct orientation of the tag. */
00053   Homography33 homography;
00054 
00055   //! Searches through a vector of Segments to form Quads.
00056   /*  @param quads any discovered quads will be added to this list
00057    *  @param path  the segments currently part of the search
00058    *  @param parent the first segment in the quad
00059    *  @param depth how deep in the search are we?
00060    */
00061   static void search(const FloatImage& fImage, std::vector<Segment*>& path,
00062          Segment& parent, int depth, std::vector<Quad>& quads);
00063 
00064 #ifdef QUAD_INTERPOLATE
00065  private:
00066   fmat::Column<2,float> p0, p3, p01, p32;
00067 #endif
00068 
00069 };
00070 
00071  std::ostream& operator<<(std::ostream &os, const Quad &quad);
00072 
00073 } // namespace
00074 
00075 #endif

Tekkotsu v5.1CVS
Generated Mon May 9 04:58:49 2016 by Doxygen 1.6.3