Homepage
Demos
Overview
Downloads
Tutorials
Reference
Credits

VisionObjectEvent.h

Go to the documentation of this file.
00001 //-*-c++-*-
00002 #ifndef INCLUDED_VisionObjectEvent_h
00003 #define INCLUDED_VisionObjectEvent_h
00004 
00005 #include "EventBase.h"
00006 
00007 //! Extends EventBase to also include location in the visual field and distance (though distance is not implimented yet)
00008 class VisionObjectEvent : public EventBase {
00009 public:
00010   //! Constructor
00011   VisionObjectEvent()
00012     : EventBase(EventBase::visObjEGID,(unsigned int)-1,EventBase::statusETID,0),_x1(0),_x2(0),_y1(0),_y2(0),
00013       _clipLeft(false), _clipRight(false), _clipTop(false), _clipBottom(false)
00014   {}
00015   
00016   //! Constructor, pass a type id and source id
00017   VisionObjectEvent(EventTypeID_t tid, unsigned int sid)
00018     : EventBase(EventBase::visObjEGID,sid,tid,0),_x1(0),_x2(0),_y1(0),_y2(0),
00019       _clipLeft(false), _clipRight(false), _clipTop(false), _clipBottom(false)
00020   {}
00021     
00022   //! Constructor, pass the type id, source id, left, right, top, bottom, x range, and y range
00023   VisionObjectEvent(EventTypeID_t tid, unsigned int sid, float x1, float x2, float y1, float y2, float rx, float ry)
00024     : EventBase(EventBase::visObjEGID,sid,tid,0),_x1(x1),_x2(x2),_y1(y1),_y2(y2),
00025       _clipLeft(_x1<=-rx), _clipRight(_x2>=rx), _clipTop(_y1<=-ry), _clipBottom(_y2>=ry)
00026   {}
00027   
00028   //! destructor
00029   virtual ~VisionObjectEvent() {}
00030   
00031   //!@name Attribute Accessors
00032   float getLeft() const { return _x1;} //!< returns the initial x coordinate of the Bounding Box
00033   VisionObjectEvent& setLeft(float x1) { _x1=x1; return *this;} //!< sets the initial x coordinate of the Bounding Box
00034   
00035   float getRight() const { return _x2;} //!< returns the final x coordinate of the Bounding Box
00036   VisionObjectEvent& setRight(float x2) { _x2=x2; return *this;} //!< sets the final x coordinate of the Bounding Box
00037   
00038   float getTop() const { return _y1;} //!< returns the initial y coordinate of the Bounding Box
00039   VisionObjectEvent& setTop(float y1) { _y1=y1; return *this;} //!< sets the initial y coordinate of the Bounding Box
00040   
00041   float getBottom() const { return _y2;} //!< returns the final y coordinate of the Bounding Box
00042   VisionObjectEvent& setBottom(float y2) { _y2=y2; return *this;} //!< sets the final y coordinate of the Bounding Box
00043   //@}
00044  
00045   //!@name Calculated Attributes
00046   float getCenterX() const { return (_x1+_x2)/2; } //!< returns the center along x
00047   float getCenterY() const { return (_y1+_y2)/2; } //!< returns the center along y
00048   float getWidth() const { return _x2-_x1; } //!< return width along x
00049   float getHeight() const { return _x2-_x1; } //!< return height along y
00050   float getArea() const { return (_x2-_x1)*(_y2-_y1); } //!< returns the final x coordinate of the Bounding Box
00051   //@}
00052 
00053   //!@name Object out of bounds Detection Functions
00054   bool isClippedLeft() const { return _clipLeft; } //!< returns #_clipLeft
00055   bool isClippedRight() const { return _clipRight; }  //!< returns #_clipRight
00056   bool isClippedTop() const { return _clipTop; } //!< returns #_clipTop
00057   bool isClippedBottom() const {return _clipBottom; } //!< returns #_clipBottom
00058   void setClipping(bool left, bool right, bool top, bool bottom) { _clipLeft=left; _clipRight=right; _clipTop=top; _clipBottom=bottom; } //!< sets clipping boundaries
00059   //@}
00060       
00061   virtual std::string getDescription(bool showTypeSpecific=true, unsigned int verbosity=0) const;
00062   
00063   virtual unsigned int getBinSize() const;
00064   virtual unsigned int LoadBuffer(const char buf[], unsigned int len);
00065   virtual unsigned int SaveBuffer(char buf[], unsigned int len) const;
00066 
00067 protected:
00068   float _x1;  //!< a value representing location in visual field - from -1 if on the left edge to 1 if it's on the right edge
00069   float _x2;  //!< a value representing location in visual field - from -1 if on the bottom edge to 1 if it's on the top edge
00070   float _y1;  //!< top boundary, in approximate range (+/- 160/208) for ERS-7; actual values vary depending on aspect ratio to keep square coordinates
00071   float _y2;  //!< top boundary, in approximate range (+/- 160/208) for ERS-7; actual values vary depending on aspect ratio to keep square coordinates
00072   bool _clipLeft;   //!< flag to indicate left boundary is on or beyond the camera image's boundary
00073   bool _clipRight;  //!< flag to indicate right boundary is on or beyond the camera image's boundary
00074   bool _clipTop;    //!< flag to indicate top boundary is on or beyond the camera image's boundary
00075   bool _clipBottom; //!< flag to indicate bottom boundary is on or beyond the camera image's boundary
00076 };
00077 
00078 /*! @file
00079  * @brief Describes VisionObjectEvent, which provides information about objects recognized in the camera image
00080  * @author alokl (Creator)
00081  * @author Ignacio Herrero Reder <nhr at dte uma es> (VisionObjectInfo Boundary Box - bug 74)
00082  *
00083  * $Author: ejt $
00084  * $Name: tekkotsu-2_3 $
00085  * $Revision: 1.5 $
00086  * $State: Exp $
00087  * $Date: 2005/01/12 21:48:17 $
00088  */
00089 
00090 #endif

Tekkotsu v2.3
Generated Sat Jan 29 02:25:24 2005 by Doxygen 1.4.0