00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
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
00050 void printOn(std::ostream &out) const;
00051
00052
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
00121 e_VISUALROI_type m_type;
00122
00123 int m_perimLength;
00124
00125 short *m_perim;
00126
00127 float *m_normVects;
00128
00129 int m_xCen;
00130
00131 int m_yCen;
00132
00133 int m_hsX;
00134
00135 int m_hsY;
00136
00137 int m_angle;
00138
00139 int m_area;
00140
00141 unsigned char *m_mask;
00142 };
00143
00144 }
00145
00146 #endif