Tekkotsu Homepage
Demos
Overview
Downloads
Dev. Resources
Reference
Credits

EndPoint.h

Go to the documentation of this file.
00001 //-*-c++-*-
00002 #ifndef _ENDPOINT_H_
00003 #define _ENDPOINT_H_
00004 
00005 #include "Shared/Measures.h"
00006 #include "Point.h"
00007 
00008 namespace DualCoding {
00009 
00010 class EndPoint : public Point {
00011 private: 
00012   //! @a valid indicates whether or not this is known to be the final end-point of the line.
00013   /*! If false, this was the point at which the line went off-camera, not the true end point. */
00014   bool valid;
00015 
00016   //! @a active indicates whether or not the line is to terminate at this point.  
00017   /*! If false, the line will continue infinitely as a ray beyond this point. */
00018   bool active;
00019 
00020   //! @a rendering_valid is set when the line is rendered and cleared if an endpoint is modified
00021   mutable bool rendering_valid;
00022 
00023   //! How many measurements have gone into the estimate of this point.
00024   int nsamples;
00025   
00026 public:
00027   friend class LineData;
00028   friend class BoundaryDetector;
00029   friend class PolygonData;
00030   
00031   EndPoint()
00032     : Point(), valid(true), active(true), rendering_valid(false), nsamples(1) {};
00033 
00034   EndPoint(coordinate_t const &xp, coordinate_t const &yp, coordinate_t const &zp=0) 
00035     : Point(xp,yp,zp), valid(true), active(true), rendering_valid(false), nsamples(1) {};
00036 
00037   EndPoint(const Point& otherPt)
00038     : Point(otherPt), valid(true), active(true), rendering_valid(false), nsamples(1) {};
00039 
00040   bool isValid() const { return valid; }
00041   void setValid(bool _valid) { valid = _valid; }
00042 
00043   bool isActive() const { return active; }
00044   void setActive(bool _active) { 
00045     if ( active != _active ) rendering_valid = false;
00046     active = _active;
00047   }
00048 
00049   bool isMatchFor(const EndPoint& other, float dist_thresh) const {return distanceFrom(other) <= dist_thresh; }
00050   bool operator==(const EndPoint& other) const { return isMatchFor(other,5); }
00051 
00052 
00053   //! Checks if endpoint comes to close to edge of camera frame and if so,
00054   //! marks it as invalid.
00055   void checkValidity(int width, int height, int edge_thresh);
00056 
00057   void updateParams(const EndPoint& other);
00058   void updateParams(const EndPoint& other, unsigned int num_updates);
00059 
00060 private:
00061   void clearNumUpdates(void) { nsamples=0; };
00062   void setNumUpdates(long _nsamples) { nsamples = _nsamples; };
00063 
00064 public:
00065   void incrementNumUpdates(void) { nsamples++; };
00066   void decrementNumUpdates(void) { nsamples--; };
00067   int numUpdates(void) const { return nsamples; };
00068 };
00069 
00070 } // namespace
00071 
00072 #endif

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