Tekkotsu Homepage
Demos
Overview
Downloads
Dev. Resources
Reference
Credits

Edge.h

Go to the documentation of this file.
00001 #ifndef EDGE_H
00002 #define EDGE_H
00003 
00004 #include <vector>
00005 
00006 #include "Vision/AprilTags/FloatImage.h"
00007 
00008 namespace AprilTags {
00009 
00010 class FloatImage;
00011 class UnionFindSimple;
00012 
00013 using std::min;
00014 using std::max;
00015 
00016 //! Represents an edge between adjacent pixels in the image.
00017 /*! The edge is encoded by the indices of the two pixels. Edge cost
00018  *  is proportional to the difference in local orientations.
00019  */
00020 class Edge {
00021 public:
00022   static float const minMag;   //!< minimum intensity gradient for an edge to be recognized
00023   static float const maxEdgeCost;   //!< 30 degrees = maximum acceptable difference in local orientations
00024   static int const WEIGHT_SCALE; // was 10000
00025   static float const thetaThresh; //!< theta threshold for merging edges
00026   static float const magThresh; //!< magnitude threshold for merging edges
00027 
00028   int pixelIdxA;
00029   int pixelIdxB;
00030   short int cost;
00031 
00032   //! Constructor
00033   Edge() : pixelIdxA(), pixelIdxB(), cost() {}
00034 
00035   //! Compare edges based on cost
00036   inline bool operator< (const Edge &other) const { return (cost < other.cost); }
00037 
00038   //! Cost of an edge between two adjacent pixels; -1 if no edge here
00039   /*! An edge exists between adjacent pixels if the magnitude of the
00040     intensity gradient at both pixels is above threshold.  The edge
00041     cost is proportional to the difference in the local orientation at
00042     the two pixels.  Lower cost is better.  A cost of -1 means there
00043     is no edge here (intensity gradien fell below threshold).
00044    */
00045   static short int edgeCost(float  theta0, float theta1, float mag1);
00046 
00047   //! Calculates and inserts up to four edges into 'edges', a vector of Edges.
00048   static void calcEdges(float theta0, int x, int y,
00049       const FloatImage& theta, const FloatImage& mag,
00050       std::vector<Edge> &edges, size_t &nEdges);
00051 
00052   //! Process edges in order of increasing cost, merging clusters if we can do so without exceeding the thetaThresh.
00053   static void mergeEdges(std::vector<Edge> &edges, UnionFindSimple &uf, float tmin[], float tmax[], float mmin[], float mmax[]);
00054 
00055 };
00056 
00057 } // namespace
00058 
00059 #endif

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