Main Page | Namespace List | Class Hierarchy | Alphabetical List | Data Structures | Directories | File List | Namespace Members | Data Fields | Globals

VisualROI.h

Go to the documentation of this file.
00001 /* Copyright (C) 2005 Pierre Moisan (Pierre.Moisan@USherbrooke.ca) 
00002 
00003    This library is free software; you can redistribute it and/or
00004    modify it under the terms of the GNU Lesser General Public
00005    License as published by the Free Software Foundation; either
00006    version 2.1 of the License, or (at your option) any later version.
00007    
00008    This library is distributed in the hope that it will be useful,
00009    but WITHOUT ANY WARRANTY; without even the implied warranty of
00010    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011    Lesser General Public License for more details.
00012    
00013    You should have received a copy of the GNU Lesser General Public
00014    License along with this library; if not, write to the Free Software
00015    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00016 */
00017 
00018 #ifndef _VISUALROI_H_
00019 #define _VISUALROI_H_
00020 
00021 #include "Object.h"
00022 #include <iostream>
00023 #include <math.h>
00024 #include "cv.h"
00025 
00026 namespace RobotFlow {
00027 
00028 typedef enum
00029 {
00030         e_VISUALROI_rectangular = 0,
00031         e_VISUALROI_elliptical,
00032         e_VISUALROI_unknown
00033 } e_VISUALROI_type;
00034 
00035 class VisualROI : public FD::Object
00036 {
00037 public:
00038         VisualROI();
00039         
00040         VisualROI(e_VISUALROI_type i_type, int i_xCen, int i_yCen,
00041                 int i_hsX, int i_hsY, int i_angle);
00042         
00043         VisualROI(const VisualROI& i_ref);
00044 
00045         virtual ~VisualROI();
00046         
00047         VisualROI & operator =(const VisualROI &i_ref);
00048 
00049         // Default routine to print a VisualROI object to an output stream
00050         void printOn(std::ostream &out) const;
00051 
00052         // Default routine to read a VisualROI object from an input stream
00053         void readFrom(std::istream &in);
00054         
00055         void DrawROI(IplImage *io_frame, const unsigned char *i_color) const;
00056         
00057         void DrawROI(int i_width, int i_height, int i_numChannels, 
00058                 unsigned char *io_pixels, const unsigned char *i_color) const;
00059 
00060         void Reset(int i_hsX, int i_hsY, int i_angle);
00061 
00062         e_VISUALROI_type GetType() const;
00063 
00064         int GetPerimLength() const;
00065 
00066         short *GetPerim();
00067         
00068         const short *GetCstPerim() const;
00069 
00070         float *GetNormVects();
00071         
00072         const float *GetCstNormVects() const;
00073         
00074         int GetXCen() const;
00075         
00076         int GetYCen() const;
00077 
00078         int GetHSX() const;
00079 
00080         int GetHSY() const;
00081         
00082         int GetAngle() const;
00083 
00084         int GetArea() const;
00085 
00086         unsigned char *GetMask();
00087         
00088         const unsigned char *GetCstMask() const;
00089         
00090         void SetType(e_VISUALROI_type i_type);
00091         
00092         void SetXCen(int i_xCen);
00093         
00094         void SetYCen(int i_yCen);
00095 
00096         void SetHSX(int i_hsX);
00097 
00098         void SetHSY(int i_hsY);
00099         
00100         void SetAngle(int i_angle);
00101 
00102 private:
00103         void DrawRectangularRegion(IplImage *io_frame, const unsigned char *i_color) const;
00104         
00105         void DrawEllipticalRegion(IplImage *io_frame, const unsigned char *i_color) const;
00106         
00107         void DrawRectangularRegion(int i_width, int i_height, int i_numChannels, 
00108                 unsigned char *io_pixels, const unsigned char *i_color) const;
00109         
00110         void DrawEllipticalRegion(int i_width, int i_height, int i_numChannels, 
00111                 unsigned char *io_pixels, const unsigned char *i_color) const;
00112         
00113         void MakeRectangularRegion();
00114         
00115         void MakeEllipticalRegion();
00116 
00117         int MakeRegionMask();
00118 
00119 private:
00120         // Region geometric type
00121         e_VISUALROI_type m_type;
00122         // Number of pixels along perimeter
00123         int m_perimLength;
00124         // Perimeter pixels
00125         short *m_perim;
00126         // Contour normal vectors
00127         float *m_normVects;
00128         // X value for the region center position
00129         int m_xCen;
00130         // Y value for the region center position
00131         int m_yCen;
00132         // Halfsize for x axis
00133         int m_hsX;
00134         // Halfsize for y axis
00135         int m_hsY;
00136         // Orientation of the region in degrees
00137         int m_angle;
00138         // Number of pixels in mask
00139         int m_area;
00140         // (2*m_hsX+1) X (2*m_hsY+1) region
00141         unsigned char *m_mask;
00142 };
00143 
00144 }
00145 
00146 #endif

Generated on Wed Oct 5 14:36:12 2005 for RobotFlow by  doxygen 1.4.4