Blob.h
Go to the documentation of this file.
00001 /************************************************************************
00002                         Blob.h
00003                         
00004 FUNCIONALITAT: Definició de la classe CBlob
00005 AUTOR: Inspecta S.L.
00006 MODIFICACIONS (Modificació, Autor, Data):
00007 
00008 FUNCTIONALITY: Definition of the CBlob class and some helper classes to perform
00009                            some calculations on it
00010 AUTHOR: Inspecta S.L.
00011 MODIFICATIONS (Modification, Author, Date):
00012 
00013 **************************************************************************/
00014 
00016 //#pragma warning( disable : 4786 ) 
00017 
00018 #ifndef CBLOB_INSPECTA_INCLUDED
00019 #define CBLOB_INSPECTA_INCLUDED
00020 
00021 #include "cxcore.h"
00022 #include "BlobLibraryConfiguration.h"
00023 #include "BlobContour.h"
00024 
00025 
00026 #ifdef BLOB_OBJECT_FACTORY
00027 
00028         #include "..\inspecta\DesignPatterns\ObjectFactory.h"
00029 #endif
00030 
00031 
00033 typedef unsigned int t_labelType;
00034 
00035 
00037 class CBlob
00038 {
00039         typedef std::list<CBlobContour> t_contourList;
00040 
00041 public:
00042         CBlob();
00043         CBlob( t_labelType id, CvPoint startPoint, CvSize originalImageSize );
00044         ~CBlob();
00045 
00047         CBlob( const CBlob &src );
00048         CBlob( const CBlob *src );
00049 
00052         CBlob& operator=(const CBlob &src );
00053         
00055         void AddInternalContour( const CBlobContour &newContour );
00056         
00058         CBlobContour *GetExternalContour()
00059         {
00060                 return &m_externalContour;
00061         }
00062 
00064         CvMemStorage *GetStorage()
00065         {
00066                 return m_storage;
00067         }
00068 
00070         t_labelType GetID()
00071         {
00072                 return m_id;
00073         }
00075         int       Exterior( IplImage *mask, bool xBorder = true, bool yBorder = true );
00077         double Area();
00079         double Perimeter();
00081         double Moment(int p, int q);
00082 
00084         double ExternPerimeter( IplImage *mask, bool xBorder  = true, bool yBorder = true );
00085         
00087         double Mean( IplImage *image );
00088 
00090         double StdDev( IplImage *image );
00091 
00094         bool IsEmpty();
00095 
00098         t_PointList GetConvexHull();
00099 
00102         void FillBlob( IplImage *imatge, CvScalar color, int offsetX = 0, int offsetY = 0 );
00103 
00105         void JoinBlob( CBlob *blob );
00106 
00108         CvRect GetBoundingBox();
00110         CvBox2D GetEllipse();
00111 
00113         double MinX()
00114         {
00115                 return GetBoundingBox().x;
00116         }
00118         double MinY()
00119         {
00120                 return GetBoundingBox().y;
00121         }
00123         double MaxX()
00124         {
00125                 return GetBoundingBox().x + GetBoundingBox().width;
00126         }
00128         double MaxY()
00129         {
00130                 return GetBoundingBox().y + GetBoundingBox().height;
00131         }
00132 private:
00133         
00135         void ClearContours();
00137         // Blob contours
00139 
00140 
00142         CvMemStorage *m_storage;
00144         CBlobContour m_externalContour;
00146         t_contourList m_internalContours;
00147 
00149         // Blob features
00151         
00153         t_labelType m_id;
00155         double m_area;
00157         double m_perimeter;
00159         double m_externPerimeter;
00161         double m_meanGray;
00163         double m_stdDevGray;
00165         CvRect m_boundingBox;
00167         CvBox2D m_ellipse;
00169         CvSize m_originalImageSize;
00170 };
00171 
00172 #endif //CBLOB_INSPECTA_INCLUDED


hrl_cvblobslib
Author(s): kelsey
autogenerated on Wed Nov 27 2013 11:32:58