Tekkotsu Homepage
Demos
Overview
Downloads
Dev. Resources
Reference
Credits

GrayModel.h

Go to the documentation of this file.
00001 //-*-c++-*-
00002 
00003 #ifndef GRAYMODEL_H
00004 #define GRAYMODEL_H
00005 
00006 #include "Shared/fmat.h"
00007 #include <vector>
00008 
00009 namespace AprilTags {
00010 
00011 //! Fits a grayscale model over an area of pixels.
00012 /*! The model is of the form: c1*x + c2*y + c3*x*y + c4 = value
00013  *
00014  * We use this model to compute spatially-varying thresholds for
00015  * reading bits.
00016  */
00017 class GrayModel {
00018 public:
00019   GrayModel();
00020 
00021   void addObservation(float x, float y, float gray);
00022 
00023   inline int getNumObservations() { return nobs; }
00024 
00025   float interpolate(float x, float y);
00026 
00027 private:
00028   void compute();
00029 
00030 // We're solving Av = b.  
00031 //
00032 // For each observation, we add a row to A of the form [x y xy 1]
00033 // and to b of the form gray*[x y xy 1].  v is the vector [c1 c2 c3 c4].
00034 //
00035 // The least-squares solution to the system is v = inv(A'A)A'b
00036 
00037   fmat::Matrix<4,4> A;
00038   fmat::Column<4> v;
00039   fmat::Column<4> b;
00040   int nobs;
00041   bool dirty;  //!< True if we've added an observation and need to recompute v
00042 };
00043 
00044 } // namespace
00045 
00046 #endif

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