diff --git a/CMakeLists.txt b/CMakeLists.txt index cf377ddd..b0985fce 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -77,7 +77,6 @@ set(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib) #------------------------------------------------------------------------------- #add subdirectories -add_subdirectory(src/3rdparty/cvblobs) if(NOT USE_SYSTEM_LIBS) add_subdirectory(src/3rdparty/libconfig) diff --git a/src/3rdparty/cvblobs/BlobContour.h b/src/3rdparty/cvblobs/BlobContour.h deleted file mode 100644 index 089c98d9..00000000 --- a/src/3rdparty/cvblobs/BlobContour.h +++ /dev/null @@ -1,99 +0,0 @@ -#ifndef BLOBCONTOUR_H_INCLUDED -#define BLOBCONTOUR_H_INCLUDED - - -#include "list" -#include -//#include "cxtypes.h" //AO -#include // - -//! Type of chain codes -typedef unsigned char t_chainCode; -//! Type of list of chain codes -typedef CvSeq* t_chainCodeList; -//! Type of list of points -typedef CvSeq* t_PointList; - - -//! Max order of calculated moments -#define MAX_MOMENTS_ORDER 3 - - -//! Blob contour class (in crack code) -class CBlobContour -{ - friend class CBlob; - friend class CBlobProperties; //AO - -public: - //! Constructors - CBlobContour(); - CBlobContour(CvPoint startPoint, CvMemStorage *storage ); - //! Copy constructor - CBlobContour( CBlobContour *source ); - - ~CBlobContour(); - //! Assigment operator - CBlobContour& operator=( const CBlobContour &source ); - - //! Add chain code to contour - void AddChainCode(t_chainCode code); - - //! Return freeman chain coded contour - t_chainCodeList GetChainCode() - { - return m_contour; - } - - bool IsEmpty() - { - return m_contour == NULL || m_contour->total == 0; - } - - //! Return all contour points - t_chainCodeList GetContourPoints(); - -protected: - - CvPoint GetStartPoint() const - { - return m_startPoint; - } - - //! Clears chain code contour - void ResetChainCode(); - - - - //! Computes area from contour - double GetArea(); - //! Computes perimeter from contour - double GetPerimeter(); - //! Get contour moment (p,q up to MAX_CALCULATED_MOMENTS) - double GetMoment(int p, int q); - - //! Crack code list - t_chainCodeList m_contour; - -private: - //! Starting point of the contour - CvPoint m_startPoint; - //! All points from the contour - t_PointList m_contourPoints; - - - - //! Computed area from contour - double m_area; - //! Computed perimeter from contour - double m_perimeter; - //! Computed moments from contour - CvMoments m_moments; - - //! Pointer to storage - CvMemStorage *m_parentStorage; -}; - -#endif //!BLOBCONTOUR_H_INCLUDED - - diff --git a/src/3rdparty/cvblobs/BlobLibraryConfiguration.h b/src/3rdparty/cvblobs/BlobLibraryConfiguration.h deleted file mode 100644 index 45b94105..00000000 --- a/src/3rdparty/cvblobs/BlobLibraryConfiguration.h +++ /dev/null @@ -1,22 +0,0 @@ -/************************************************************************ - BlobLibraryConfiguration.h - -FUNCIONALITAT: Configuraciķ del comportament global de la llibreria -AUTOR: Inspecta S.L. -MODIFICACIONS (Modificaciķ, Autor, Data): - -FUNCTIONALITY: Global configuration of the library -AUTHOR: Inspecta S.L. -MODIFICATIONS (Modification, Author, Date): - -**************************************************************************/ - -//! Indica si es volen fer servir les MatrixCV o no -//! Use/Not use the MatrixCV class -//#define MATRIXCV_ACTIU - -//! Uses/not use the blob object factory -//#define BLOB_OBJECT_FACTORY - -//! Show/not show blob access errors -//#define _SHOW_ERRORS //AO: Only works for WIN. diff --git a/src/3rdparty/cvblobs/BlobOperators.cpp b/src/3rdparty/cvblobs/BlobOperators.cpp deleted file mode 100644 index dcbaf135..00000000 --- a/src/3rdparty/cvblobs/BlobOperators.cpp +++ /dev/null @@ -1,502 +0,0 @@ -#include -#include "BlobOperators.h" - -/*************************************************************************** - Implementaciķ de les classes per al cālcul de característiques sobre el blob - - Implementation of the helper classes to perform operations on blobs -/**************************************************************************/ - -/** -- FUNCTION: Moment -- FUNCTIONALITY: Calculates the pq moment of the blob -- PARAMETERS: -- RESULT: - - returns the pq moment or 0 if the moment it is not implemented -- RESTRICTIONS: - - Currently, implemented moments up to 3 -- AUTHOR: Ricard Borrās -- CREATION DATE: 20-07-2004. -- MODIFICATION: Date. Author. Description. -*/ -double CBlobGetMoment::operator()(CBlob &blob) -{ - return blob.Moment(m_p, m_q); -} - -/** -- FUNCIĶ: HullPerimeter -- FUNCIONALITAT: Calcula la longitud del perimetre convex del blob. - Fa servir la funciķ d'OpenCV cvConvexHull2 per a - calcular el perimetre convex. - -- PARĀMETRES: -- RESULTAT: - - retorna la longitud del perímetre convex del blob. Si el blob no té coordenades - associades retorna el perímetre normal del blob. -- RESTRICCIONS: -- AUTOR: Ricard Borrās -- DATA DE CREACIĶ: 20-07-2004. -- MODIFICACIĶ: Data. Autor. Descripciķ. -*/ -/** -- FUNCTION: CBlobGetHullPerimeter -- FUNCTIONALITY: Calculates the convex hull perimeter of the blob -- PARAMETERS: -- RESULT: - - returns the convex hull perimeter of the blob or the perimeter if the - blob edges could not be retrieved -- RESTRICTIONS: -- AUTHOR: Ricard Borrās -- CREATION DATE: 25-05-2005. -- MODIFICATION: Date. Author. Description. -*/ -double CBlobGetHullPerimeter::operator()(CBlob &blob) -{ - CvSeq *convexHull; - double perimeter; - - convexHull = blob.GetConvexHull(); - - if( convexHull ) - perimeter = fabs(cvArcLength(convexHull,CV_WHOLE_SEQ,1)); - else - return 0; - - cvClearSeq(convexHull); - - return perimeter; -} - -double CBlobGetHullArea::operator()(CBlob &blob) -{ - CvSeq *convexHull; - double area; - - convexHull = blob.GetConvexHull(); - - if( convexHull ) - area = fabs(cvContourArea(convexHull)); - else - return 0; - - cvClearSeq(convexHull); - - return area; -} - -/** -- FUNCTION: CBlobGetMinXatMinY -- FUNCTIONALITY: Calculates the minimum X on the minimum Y -- PARAMETERS: -- RESULT: -- RESTRICTIONS: -- AUTHOR: Ricard Borrās -- CREATION DATE: 25-05-2005. -- MODIFICATION: Date. Author. Description. -*/ -double CBlobGetMinXatMinY::operator()(CBlob &blob) -{ - double result = LONG_MAX; - - CvSeqReader reader; - CvPoint actualPoint; - t_PointList externContour; - - externContour = blob.GetExternalContour()->GetContourPoints(); - if( !externContour ) return result; - cvStartReadSeq( externContour, &reader); - - for( int i=0; i< externContour->total; i++) - { - CV_READ_SEQ_ELEM( actualPoint, reader); - - if( (actualPoint.y == blob.MinY()) && (actualPoint.x < result) ) - { - result = actualPoint.x; - } - } - - return result; -} - -/** -- FUNCTION: CBlobGetMinXatMinY -- FUNCTIONALITY: Calculates the minimum Y on the maximum X -- PARAMETERS: -- RESULT: -- RESTRICTIONS: -- AUTHOR: Ricard Borrās -- CREATION DATE: 25-05-2005. -- MODIFICATION: Date. Author. Description. -*/ -double CBlobGetMinYatMaxX::operator()(CBlob &blob) -{ - double result = LONG_MAX; - - CvSeqReader reader; - CvPoint actualPoint; - t_PointList externContour; - - externContour = blob.GetExternalContour()->GetContourPoints(); - if( !externContour ) return result; - cvStartReadSeq( externContour, &reader); - - for( int i=0; i< externContour->total; i++) - { - CV_READ_SEQ_ELEM( actualPoint, reader); - - if( (actualPoint.x == blob.MaxX()) && (actualPoint.y < result) ) - { - result = actualPoint.y; - } - } - - return result; -} - -/** -- FUNCTION: CBlobGetMaxXatMaxY -- FUNCTIONALITY: Calculates the maximum X on the maximum Y -- PARAMETERS: -- RESULT: -- RESTRICTIONS: -- AUTHOR: Ricard Borrās -- CREATION DATE: 25-05-2005. -- MODIFICATION: Date. Author. Description. -*/ -double CBlobGetMaxXatMaxY::operator()(CBlob &blob) -{ - double result = LONG_MIN; - - CvSeqReader reader; - CvPoint actualPoint; - t_PointList externContour; - - externContour = blob.GetExternalContour()->GetContourPoints(); - if( !externContour ) return result; - - cvStartReadSeq( externContour, &reader); - - for( int i=0; i< externContour->total; i++) - { - CV_READ_SEQ_ELEM( actualPoint, reader); - - if( (actualPoint.y == blob.MaxY()) && (actualPoint.x > result) ) - { - result = actualPoint.x; - } - } - - return result; -} - -/** -- FUNCTION: CBlobGetMaxYatMinX -- FUNCTIONALITY: Calculates the maximum Y on the minimum X -- PARAMETERS: -- RESULT: -- RESTRICTIONS: -- AUTHOR: Ricard Borrās -- CREATION DATE: 25-05-2005. -- MODIFICATION: Date. Author. Description. -*/ -double CBlobGetMaxYatMinX::operator()(CBlob &blob) -{ - double result = LONG_MIN; - - CvSeqReader reader; - CvPoint actualPoint; - t_PointList externContour; - - externContour = blob.GetExternalContour()->GetContourPoints(); - if( !externContour ) return result; - - cvStartReadSeq( externContour, &reader); - - - for( int i=0; i< externContour->total; i++) - { - CV_READ_SEQ_ELEM( actualPoint, reader); - - if( (actualPoint.x == blob.MinX()) && (actualPoint.y > result) ) - { - result = actualPoint.y; - } - } - - return result; -} - - -/** -- FUNCTION: CBlobGetElongation -- FUNCTIONALITY: Calculates the elongation of the blob ( length/breadth ) -- PARAMETERS: -- RESULT: -- RESTRICTIONS: - - See below to see how the lenght and the breadth are aproximated -- AUTHOR: Ricard Borrās -- CREATION DATE: 25-05-2005. -- MODIFICATION: Date. Author. Description. -*/ -double CBlobGetElongation::operator()(CBlob &blob) -{ - double ampladaC,longitudC,amplada,longitud; - - double tmp; - - tmp = blob.Perimeter()*blob.Perimeter() - 16*blob.Area(); - - if( tmp > 0.0 ) - ampladaC = (double) (blob.Perimeter()+sqrt(tmp))/4; - // error intrínsec en els cālculs de l'ārea i el perímetre - else - ampladaC = (double) (blob.Perimeter())/4; - - if(ampladaC<=0.0) return 0; - longitudC=(double) blob.Area()/ampladaC; - - longitud=MAX( longitudC , ampladaC ); - amplada=MIN( longitudC , ampladaC ); - - return (double) longitud/amplada; -} - -/** - Retorna la compacitat del blob -*/ -/** -- FUNCTION: CBlobGetCompactness -- FUNCTIONALITY: Calculates the compactness of the blob - ( maximum for circle shaped blobs, minimum for the rest) -- PARAMETERS: -- RESULT: -- RESTRICTIONS: -- AUTHOR: Ricard Borrās -- CREATION DATE: 25-05-2005. -- MODIFICATION: Date. Author. Description. -*/ -double CBlobGetCompactness::operator()(CBlob &blob) -{ - if( blob.Area() != 0.0 ) - return (double) pow(blob.Perimeter(),2)/(4*CV_PI*blob.Area()); - else - return 0.0; -} - -/** - Retorna la rugositat del blob -*/ -/** -- FUNCTION: CBlobGetRoughness -- FUNCTIONALITY: Calculates the roughness of the blob - ( ratio between perimeter and convex hull perimeter) -- PARAMETERS: -- RESULT: -- RESTRICTIONS: -- AUTHOR: Ricard Borrās -- CREATION DATE: 25-05-2005. -- MODIFICATION: Date. Author. Description. -*/ -double CBlobGetRoughness::operator()(CBlob &blob) -{ - CBlobGetHullPerimeter getHullPerimeter = CBlobGetHullPerimeter(); - - double hullPerimeter = getHullPerimeter(blob); - - if( hullPerimeter != 0.0 ) - return blob.Perimeter() / hullPerimeter;//HullPerimeter(); - - return 0.0; -} - -/** - Retorna la longitud del blob -*/ -/** -- FUNCTION: CBlobGetLength -- FUNCTIONALITY: Calculates the lenght of the blob (the biggest axis of the blob) -- PARAMETERS: -- RESULT: -- RESTRICTIONS: - - The lenght is an aproximation to the real lenght -- AUTHOR: Ricard Borrās -- CREATION DATE: 25-05-2005. -- MODIFICATION: Date. Author. Description. -*/ -double CBlobGetLength::operator()(CBlob &blob) -{ - double ampladaC,longitudC; - double tmp; - - tmp = blob.Perimeter()*blob.Perimeter() - 16*blob.Area(); - - if( tmp > 0.0 ) - ampladaC = (double) (blob.Perimeter()+sqrt(tmp))/4; - // error intrínsec en els cālculs de l'ārea i el perímetre - else - ampladaC = (double) (blob.Perimeter())/4; - - if(ampladaC<=0.0) return 0; - longitudC=(double) blob.Area()/ampladaC; - - return MAX( longitudC , ampladaC ); -} - -/** - Retorna l'amplada del blob -*/ -/** -- FUNCTION: CBlobGetBreadth -- FUNCTIONALITY: Calculates the breadth of the blob (the smallest axis of the blob) -- PARAMETERS: -- RESULT: -- RESTRICTIONS: - - The breadth is an aproximation to the real breadth -- AUTHOR: Ricard Borrās -- CREATION DATE: 25-05-2005. -- MODIFICATION: Date. Author. Description. -*/ -double CBlobGetBreadth::operator()(CBlob &blob) -{ - double ampladaC,longitudC; - double tmp; - - tmp = blob.Perimeter()*blob.Perimeter() - 16*blob.Area(); - - if( tmp > 0.0 ) - ampladaC = (double) (blob.Perimeter()+sqrt(tmp))/4; - // error intrínsec en els cālculs de l'ārea i el perímetre - else - ampladaC = (double) (blob.Perimeter())/4; - - if(ampladaC<=0.0) return 0; - longitudC = (double) blob.Area()/ampladaC; - - return MIN( longitudC , ampladaC ); -} - -/** - Calcula la distāncia entre un punt i el centre del blob -*/ -/** -- FUNCTION: CBlobGetDistanceFromPoint -- FUNCTIONALITY: Calculates the euclidean distance between the blob center and - the point specified in the constructor -- PARAMETERS: -- RESULT: -- RESTRICTIONS: -- AUTHOR: Ricard Borrās -- CREATION DATE: 25-05-2005. -- MODIFICATION: Date. Author. Description. -*/ -double CBlobGetDistanceFromPoint::operator()(CBlob &blob) -{ - double xmitjana, ymitjana; - CBlobGetXCenter getXCenter; - CBlobGetYCenter getYCenter; - - xmitjana = m_x - getXCenter( blob ); - ymitjana = m_y - getYCenter( blob ); - - return sqrt((xmitjana*xmitjana)+(ymitjana*ymitjana)); -} - -/** -- FUNCTION: BlobGetXYInside -- FUNCTIONALITY: Calculates whether a point is inside the - rectangular bounding box of a blob -- PARAMETERS: -- RESULT: - - returns 1 if it is inside; o if not -- RESTRICTIONS: -- AUTHOR: Francesc Pinyol Margalef -- CREATION DATE: 16-01-2006. -- MODIFICATION: Date. Author. Description. -*/ -double CBlobGetXYInside::operator()(CBlob &blob) -{ - if( blob.GetExternalContour()->GetContourPoints() ) - { - return cvPointPolygonTest( blob.GetExternalContour()->GetContourPoints(), m_p,0) >= 0; - } - - return 0; -} -#ifdef BLOB_OBJECT_FACTORY - -/** -- FUNCIĶ: RegistraTotsOperadors -- FUNCIONALITAT: Registrar tots els operadors definits a blob.h -- PARĀMETRES: - - fabricaOperadorsBlob: fābrica on es registraran els operadors -- RESULTAT: - - Modifica l'objecte fabricaOperadorsBlob -- RESTRICCIONS: - - Només es registraran els operadors de blob.h. Si se'n volen afegir, cal afegir-los amb - el mčtode Register de la fābrica. -- AUTOR: rborras -- DATA DE CREACIĶ: 2006/05/18 -- MODIFICACIĶ: Data. Autor. Descripciķ. -*/ -void RegistraTotsOperadors( t_OperadorBlobFactory &fabricaOperadorsBlob ) -{ - // blob shape - fabricaOperadorsBlob.Register( CBlobGetArea().GetNom(), Type2Type()); - fabricaOperadorsBlob.Register( CBlobGetBreadth().GetNom(), Type2Type()); - fabricaOperadorsBlob.Register( CBlobGetCompactness().GetNom(), Type2Type()); - fabricaOperadorsBlob.Register( CBlobGetElongation().GetNom(), Type2Type()); - fabricaOperadorsBlob.Register( CBlobGetExterior().GetNom(), Type2Type()); - fabricaOperadorsBlob.Register( CBlobGetLength().GetNom(), Type2Type()); - fabricaOperadorsBlob.Register( CBlobGetPerimeter().GetNom(), Type2Type()); - fabricaOperadorsBlob.Register( CBlobGetRoughness().GetNom(), Type2Type()); - - // blob color - fabricaOperadorsBlob.Register( CBlobGetMean(NULL).GetNom(), Type2Type()); - fabricaOperadorsBlob.Register( CBlobGetStdDev(NULL).GetNom(), Type2Type()); - - // extern pixels - fabricaOperadorsBlob.Register( CBlobGetExternPerimeterRatio().GetNom(), Type2Type()); - fabricaOperadorsBlob.Register( CBlobGetExternHullPerimeterRatio().GetNom(), Type2Type()); - fabricaOperadorsBlob.Register( CBlobGetExternPerimeter().GetNom(), Type2Type()); - - - // hull - fabricaOperadorsBlob.Register( CBlobGetHullPerimeter().GetNom(), Type2Type()); - fabricaOperadorsBlob.Register( CBlobGetHullArea().GetNom(), Type2Type()); - - - // elipse info - fabricaOperadorsBlob.Register( CBlobGetMajorAxisLength().GetNom(), Type2Type()); - fabricaOperadorsBlob.Register( CBlobGetMinorAxisLength().GetNom(), Type2Type()); - fabricaOperadorsBlob.Register( CBlobGetAxisRatio().GetNom(), Type2Type()); - fabricaOperadorsBlob.Register( CBlobGetOrientation().GetNom(), Type2Type()); - fabricaOperadorsBlob.Register( CBlobGetOrientationCos().GetNom(), Type2Type()); - fabricaOperadorsBlob.Register( CBlobGetAreaElipseRatio().GetNom(), Type2Type()); - - // min an max - fabricaOperadorsBlob.Register( CBlobGetMaxX().GetNom(), Type2Type()); - fabricaOperadorsBlob.Register( CBlobGetMaxY().GetNom(), Type2Type()); - fabricaOperadorsBlob.Register( CBlobGetMinX().GetNom(), Type2Type()); - fabricaOperadorsBlob.Register( CBlobGetMinY().GetNom(), Type2Type()); - - fabricaOperadorsBlob.Register( CBlobGetMaxXatMaxY().GetNom(), Type2Type()); - fabricaOperadorsBlob.Register( CBlobGetMaxYatMinX().GetNom(), Type2Type()); - fabricaOperadorsBlob.Register( CBlobGetMinXatMinY().GetNom(), Type2Type()); - fabricaOperadorsBlob.Register( CBlobGetMinYatMaxX().GetNom(), Type2Type()); - - // coordinate info - fabricaOperadorsBlob.Register( CBlobGetXYInside().GetNom(), Type2Type()); - fabricaOperadorsBlob.Register( CBlobGetDiffY().GetNom(), Type2Type()); - fabricaOperadorsBlob.Register( CBlobGetDiffX().GetNom(), Type2Type()); - fabricaOperadorsBlob.Register( CBlobGetXCenter().GetNom(), Type2Type()); - fabricaOperadorsBlob.Register( CBlobGetYCenter().GetNom(), Type2Type()); - fabricaOperadorsBlob.Register( CBlobGetDistanceFromPoint().GetNom(), Type2Type()); - - // moments - fabricaOperadorsBlob.Register( CBlobGetMoment().GetNom(), Type2Type()); - -} - -#endif //BLOB_OBJECT_FACTORY \ No newline at end of file diff --git a/src/3rdparty/cvblobs/BlobOperators.h b/src/3rdparty/cvblobs/BlobOperators.h deleted file mode 100644 index 8be3c282..00000000 --- a/src/3rdparty/cvblobs/BlobOperators.h +++ /dev/null @@ -1,754 +0,0 @@ -#ifndef BLOB_OPERATORS_H_INCLUDED -#define BLOB_OPERATORS_H_INCLUDED - -#include "blob.h" - -/************************************************************************** - Definiciķ de les classes per a fer operacions sobre els blobs - - Helper classes to perform operations on blobs -**************************************************************************/ - -//! Factor de conversiķ de graus a radians -#define DEGREE2RAD (CV_PI / 180.0) - - -//! Classe d'on derivarem totes les operacions sobre els blobs -//! Interface to derive all blob operations -class COperadorBlob -{ -public: - virtual ~COperadorBlob(){}; - - //! Aply operator to blob - virtual double operator()(CBlob &blob) = 0; - //! Get operator name - virtual const char *GetNom() = 0; - - operator COperadorBlob*() - { - return (COperadorBlob*)this; - } -}; - -typedef COperadorBlob funcio_calculBlob; - -#ifdef BLOB_OBJECT_FACTORY - /** - Funciķ per comparar dos identificadors dins de la fābrica de COperadorBlobs - */ - struct functorComparacioIdOperador - { - bool operator()(const char* s1, const char* s2) const - { - return strcmp(s1, s2) < 0; - } - }; - - //! Definition of Object factory type for COperadorBlob objects - typedef ObjectFactory t_OperadorBlobFactory; - - //! Funciķ global per a registrar tots els operadors definits a blob.h - void RegistraTotsOperadors( t_OperadorBlobFactory &fabricaOperadorsBlob ); - -#endif - - -//! Classe per calcular l'etiqueta d'un blob -//! Class to get ID of a blob -class CBlobGetID : public COperadorBlob -{ -public: - double operator()(CBlob &blob) - { - return blob.GetID(); - } - const char *GetNom() - { - return "CBlobGetID"; - } -}; - - -//! Classe per calcular l'ārea d'un blob -//! Class to get the area of a blob -class CBlobGetArea : public COperadorBlob -{ -public: - double operator()(CBlob &blob) - { - return blob.Area(); - } - const char *GetNom() - { - return "CBlobGetArea"; - } -}; - -//! Classe per calcular el perimetre d'un blob -//! Class to get the perimeter of a blob -class CBlobGetPerimeter: public COperadorBlob -{ -public: - double operator()(CBlob &blob) - { - return blob.Perimeter(); - } - const char *GetNom() - { - return "CBlobGetPerimeter"; - } -}; - -//! Classe que diu si un blob és extern o no -//! Class to get the extern flag of a blob -class CBlobGetExterior: public COperadorBlob -{ -public: - CBlobGetExterior() - { - m_mask = NULL; - m_xBorder = false; - m_yBorder = false; - } - CBlobGetExterior(IplImage *mask, bool xBorder = true, bool yBorder = true) - { - m_mask = mask; - m_xBorder = xBorder; - m_yBorder = yBorder; - } - double operator()(CBlob &blob) - { - return blob.Exterior(m_mask, m_xBorder, m_yBorder); - } - const char *GetNom() - { - return "CBlobGetExterior"; - } -private: - IplImage *m_mask; - bool m_xBorder, m_yBorder; -}; - -//! Classe per calcular la mitjana de nivells de gris d'un blob -//! Class to get the mean grey level of a blob -class CBlobGetMean: public COperadorBlob -{ -public: - CBlobGetMean() - { - m_image = NULL; - } - CBlobGetMean( IplImage *image ) - { - m_image = image; - }; - - double operator()(CBlob &blob) - { - return blob.Mean(m_image); - } - const char *GetNom() - { - return "CBlobGetMean"; - } -private: - - IplImage *m_image; -}; - -//! Classe per calcular la desviaciķ estāndard dels nivells de gris d'un blob -//! Class to get the standard deviation of the grey level values of a blob -class CBlobGetStdDev: public COperadorBlob -{ -public: - CBlobGetStdDev() - { - m_image = NULL; - } - CBlobGetStdDev( IplImage *image ) - { - m_image = image; - }; - double operator()(CBlob &blob) - { - return blob.StdDev(m_image); - } - const char *GetNom() - { - return "CBlobGetStdDev"; - } -private: - - IplImage *m_image; - -}; - -//! Classe per calcular la compacitat d'un blob -//! Class to calculate the compactness of a blob -class CBlobGetCompactness: public COperadorBlob -{ -public: - double operator()(CBlob &blob); - const char *GetNom() - { - return "CBlobGetCompactness"; - } -}; - -//! Classe per calcular la longitud d'un blob -//! Class to calculate the length of a blob -class CBlobGetLength: public COperadorBlob -{ -public: - double operator()(CBlob &blob); - const char *GetNom() - { - return "CBlobGetLength"; - } -}; - -//! Classe per calcular l'amplada d'un blob -//! Class to calculate the breadth of a blob -class CBlobGetBreadth: public COperadorBlob -{ -public: - double operator()(CBlob &blob); - const char *GetNom() - { - return "CBlobGetBreadth"; - } -}; - -//! Classe per calcular la diferčncia en X del blob -class CBlobGetDiffX: public COperadorBlob -{ -public: - double operator()(CBlob &blob) - { - return blob.GetBoundingBox().width; - } - const char *GetNom() - { - return "CBlobGetDiffX"; - } -}; - -//! Classe per calcular la diferčncia en X del blob -class CBlobGetDiffY: public COperadorBlob -{ -public: - double operator()(CBlob &blob) - { - return blob.GetBoundingBox().height; - } - const char *GetNom() - { - return "CBlobGetDiffY"; - } -}; - -//! Classe per calcular el moment PQ del blob -//! Class to calculate the P,Q moment of a blob -class CBlobGetMoment: public COperadorBlob -{ -public: - //! Constructor estāndard - //! Standard constructor (gets the 00 moment) - CBlobGetMoment() - { - m_p = m_q = 0; - } - //! Constructor: indiquem el moment p,q a calcular - //! Constructor: gets the PQ moment - CBlobGetMoment( int p, int q ) - { - m_p = p; - m_q = q; - }; - double operator()(CBlob &blob); - const char *GetNom() - { - return "CBlobGetMoment"; - } - -private: - //! moment que volem calcular - int m_p, m_q; -}; - -//! Classe per calcular el perimetre del poligon convex d'un blob -//! Class to calculate the convex hull perimeter of a blob -class CBlobGetHullPerimeter: public COperadorBlob -{ -public: - double operator()(CBlob &blob); - const char *GetNom() - { - return "CBlobGetHullPerimeter"; - } -}; - -//! Classe per calcular l'ārea del poligon convex d'un blob -//! Class to calculate the convex hull area of a blob -class CBlobGetHullArea: public COperadorBlob -{ -public: - double operator()(CBlob &blob); - const char *GetNom() - { - return "CBlobGetHullArea"; - } -}; - -//! Classe per calcular la x minima en la y minima -//! Class to calculate the minimum x on the minimum y -class CBlobGetMinXatMinY: public COperadorBlob -{ -public: - double operator()(CBlob &blob); - const char *GetNom() - { - return "CBlobGetMinXatMinY"; - } -}; - -//! Classe per calcular la y minima en la x maxima -//! Class to calculate the minimum y on the maximum x -class CBlobGetMinYatMaxX: public COperadorBlob -{ -public: - double operator()(CBlob &blob); - const char *GetNom() - { - return "CBlobGetMinYatMaxX"; - } -}; - -//! Classe per calcular la x maxima en la y maxima -//! Class to calculate the maximum x on the maximum y -class CBlobGetMaxXatMaxY: public COperadorBlob -{ -public: - double operator()(CBlob &blob); - const char *GetNom() - { - return "CBlobGetMaxXatMaxY"; - } -}; - -//! Classe per calcular la y maxima en la x minima -//! Class to calculate the maximum y on the minimum y -class CBlobGetMaxYatMinX: public COperadorBlob -{ -public: - double operator()(CBlob &blob); - const char *GetNom() - { - return "CBlobGetMaxYatMinX"; - } -}; - -//! Classe per a calcular la x mínima -//! Class to get the minimum x -class CBlobGetMinX: public COperadorBlob -{ -public: - double operator()(CBlob &blob) - { - return blob.MinX(); - } - const char *GetNom() - { - return "CBlobGetMinX"; - } -}; - -//! Classe per a calcular la x māxima -//! Class to get the maximum x -class CBlobGetMaxX: public COperadorBlob -{ -public: - double operator()(CBlob &blob) - { - return blob.MaxX(); - } - const char *GetNom() - { - return "CBlobGetMaxX"; - } -}; - -//! Classe per a calcular la y mínima -//! Class to get the minimum y -class CBlobGetMinY: public COperadorBlob -{ -public: - double operator()(CBlob &blob) - { - return blob.MinY(); - } - const char *GetNom() - { - return "CBlobGetMinY"; - } -}; - -//! Classe per a calcular la y māxima -//! Class to get the maximum y -class CBlobGetMaxY: public COperadorBlob -{ -public: - double operator()(CBlob &blob) - { - return blob.MaxY(); - } - const char *GetNom() - { - return "CBlobGetMaxY"; - } -}; - - -//! Classe per calcular l'elongacio d'un blob -//! Class to calculate the elongation of the blob -class CBlobGetElongation: public COperadorBlob -{ -public: - double operator()(CBlob &blob); - const char *GetNom() - { - return "CBlobGetElongation"; - } -}; - -//! Classe per calcular la rugositat d'un blob -//! Class to calculate the roughness of the blob -class CBlobGetRoughness: public COperadorBlob -{ -public: - double operator()(CBlob &blob); - const char *GetNom() - { - return "CBlobGetRoughness"; - } -}; - -//! Classe per calcular la distāncia entre el centre del blob i un punt donat -//! Class to calculate the euclidean distance between the center of a blob and a given point -class CBlobGetDistanceFromPoint: public COperadorBlob -{ -public: - //! Standard constructor (distance to point 0,0) - CBlobGetDistanceFromPoint() - { - m_x = m_y = 0.0; - } - //! Constructor (distance to point x,y) - CBlobGetDistanceFromPoint( const double x, const double y ) - { - m_x = x; - m_y = y; - } - - double operator()(CBlob &blob); - const char *GetNom() - { - return "CBlobGetDistanceFromPoint"; - } - -private: - // coordenades del punt on volem calcular la distāncia - double m_x, m_y; -}; - -//! Classe per calcular el nombre de pixels externs d'un blob -//! Class to get the number of extern pixels of a blob -class CBlobGetExternPerimeter: public COperadorBlob -{ -public: - CBlobGetExternPerimeter() - { - m_mask = NULL; - m_xBorder = false; - m_yBorder = false; - } - CBlobGetExternPerimeter( IplImage *mask, bool xBorder = true, bool yBorder = true ) - { - m_mask = mask; - m_xBorder = xBorder; - m_yBorder = yBorder; - } - double operator()(CBlob &blob) - { - return blob.ExternPerimeter(m_mask, m_xBorder, m_yBorder); - } - const char *GetNom() - { - return "CBlobGetExternPerimeter"; - } -private: - IplImage *m_mask; - bool m_xBorder, m_yBorder; -}; - -//! Classe per calcular el ratio entre el perimetre i nombre pixels externs -//! valors propers a 0 indiquen que la majoria del blob és intern -//! valors propers a 1 indiquen que la majoria del blob és extern -//! Class to calculate the ratio between the perimeter and the number of extern pixels -class CBlobGetExternPerimeterRatio: public COperadorBlob -{ -public: - CBlobGetExternPerimeterRatio() - { - m_mask = NULL; - m_xBorder = false; - m_yBorder = false; - } - CBlobGetExternPerimeterRatio( IplImage *mask, bool xBorder = true, bool yBorder = true ) - { - m_mask = mask; - m_xBorder = xBorder; - m_yBorder = yBorder; - } - double operator()(CBlob &blob) - { - if( blob.Perimeter() != 0 ) - return blob.ExternPerimeter(m_mask, m_xBorder, m_yBorder) / blob.Perimeter(); - else - return blob.ExternPerimeter(m_mask, m_xBorder, m_yBorder); - } - const char *GetNom() - { - return "CBlobGetExternPerimeterRatio"; - } -private: - IplImage *m_mask; - bool m_xBorder, m_yBorder; -}; - -//! Classe per calcular el ratio entre el perimetre convex i nombre pixels externs -//! valors propers a 0 indiquen que la majoria del blob és intern -//! valors propers a 1 indiquen que la majoria del blob és extern -//! Class to calculate the ratio between the perimeter and the number of extern pixels -class CBlobGetExternHullPerimeterRatio: public COperadorBlob -{ -public: - CBlobGetExternHullPerimeterRatio() - { - m_mask = NULL; - m_xBorder = false; - m_yBorder = false; - } - CBlobGetExternHullPerimeterRatio( IplImage *mask, bool xBorder = true, bool yBorder = true ) - { - m_mask = mask; - m_xBorder = xBorder; - m_yBorder = yBorder; - } - double operator()(CBlob &blob) - { - CBlobGetHullPerimeter getHullPerimeter; - double hullPerimeter; - - if( (hullPerimeter = getHullPerimeter( blob ) ) != 0 ) - return blob.ExternPerimeter(m_mask, m_xBorder, m_yBorder) / hullPerimeter; - else - return blob.ExternPerimeter(m_mask, m_xBorder, m_yBorder); - } - const char *GetNom() - { - return "CBlobGetExternHullPerimeterRatio"; - } -private: - IplImage *m_mask; - bool m_xBorder, m_yBorder; - -}; - -//! Classe per calcular el centre en el eix X d'un blob -//! Class to calculate the center in the X direction -class CBlobGetXCenter: public COperadorBlob -{ -public: - double operator()(CBlob &blob) - { - return blob.MinX() + (( blob.MaxX() - blob.MinX() ) / 2.0); - } - const char *GetNom() - { - return "CBlobGetXCenter"; - } -}; - -//! Classe per calcular el centre en el eix Y d'un blob -//! Class to calculate the center in the Y direction -class CBlobGetYCenter: public COperadorBlob -{ -public: - double operator()(CBlob &blob) - { - return blob.MinY() + (( blob.MaxY() - blob.MinY() ) / 2.0); - } - const char *GetNom() - { - return "CBlobGetYCenter"; - } -}; - -//! Classe per calcular la longitud de l'eix major d'un blob -//! Class to calculate the length of the major axis of the ellipse that fits the blob edges -class CBlobGetMajorAxisLength: public COperadorBlob -{ -public: - double operator()(CBlob &blob) - { - CvBox2D elipse = blob.GetEllipse(); - - return elipse.size.width; - } - const char *GetNom() - { - return "CBlobGetMajorAxisLength"; - } -}; - -//! Classe per calcular el ratio entre l'area de la elipse i la de la taca -//! Class -class CBlobGetAreaElipseRatio: public COperadorBlob -{ -public: - double operator()(CBlob &blob) - { - if( blob.Area()==0.0 ) return 0.0; - - CvBox2D elipse = blob.GetEllipse(); - double ratioAreaElipseAreaTaca = ( (elipse.size.width/2.0) - * - (elipse.size.height/2.0) - *CV_PI - ) - / - blob.Area(); - - return ratioAreaElipseAreaTaca; - } - const char *GetNom() - { - return "CBlobGetAreaElipseRatio"; - } -}; - -//! Classe per calcular la longitud de l'eix menor d'un blob -//! Class to calculate the length of the minor axis of the ellipse that fits the blob edges -class CBlobGetMinorAxisLength: public COperadorBlob -{ -public: - double operator()(CBlob &blob) - { - CvBox2D elipse = blob.GetEllipse(); - - return elipse.size.height; - } - const char *GetNom() - { - return "CBlobGetMinorAxisLength"; - } -}; - -//! Classe per calcular l'orientaciķ de l'ellipse del blob en radians -//! Class to calculate the orientation of the ellipse that fits the blob edges in radians -class CBlobGetOrientation: public COperadorBlob -{ -public: - double operator()(CBlob &blob) - { - CvBox2D elipse = blob.GetEllipse(); -/* - if( elipse.angle > 180.0 ) - return (( elipse.angle - 180.0 )* DEGREE2RAD); - else - return ( elipse.angle * DEGREE2RAD); -*/ - return elipse.angle; - } - const char *GetNom() - { - return "CBlobGetOrientation"; - } -}; - -//! Classe per calcular el cosinus de l'orientaciķ de l'ellipse del blob -//! Class to calculate the cosinus of the orientation of the ellipse that fits the blob edges -class CBlobGetOrientationCos: public COperadorBlob -{ -public: - double operator()(CBlob &blob) - { - CBlobGetOrientation getOrientation; - return fabs( cos( getOrientation(blob)*DEGREE2RAD )); - } - const char *GetNom() - { - return "CBlobGetOrientationCos"; - } -}; - - -//! Classe per calcular el ratio entre l'eix major i menor de la elˇlipse -//! Class to calculate the ratio between both axes of the ellipse -class CBlobGetAxisRatio: public COperadorBlob -{ -public: - double operator()(CBlob &blob) - { - double major,minor; - CBlobGetMajorAxisLength getMajor; - CBlobGetMinorAxisLength getMinor; - - major = getMajor(blob); - minor = getMinor(blob); - - if( major != 0 ) - return minor / major; - else - return 0; - } - const char *GetNom() - { - return "CBlobGetAxisRatio"; - } -}; - - -//! Classe per calcular si un punt cau dins del blob -//! Class to calculate whether a point is inside a blob -class CBlobGetXYInside: public COperadorBlob -{ -public: - //! Constructor estāndard - //! Standard constructor - CBlobGetXYInside() - { - m_p.x = 0; - m_p.y = 0; - } - //! Constructor: indiquem el punt - //! Constructor: sets the point - CBlobGetXYInside( CvPoint2D32f p ) - { - m_p = p; - }; - double operator()(CBlob &blob); - const char *GetNom() - { - return "CBlobGetXYInside"; - } - -private: - //! punt que considerem - //! point to be considered - CvPoint2D32f m_p; -}; - -#endif //!BLOB_OPERATORS_H_INCLUDED diff --git a/src/3rdparty/cvblobs/BlobProperties.cpp b/src/3rdparty/cvblobs/BlobProperties.cpp deleted file mode 100644 index 3d15a40e..00000000 --- a/src/3rdparty/cvblobs/BlobProperties.cpp +++ /dev/null @@ -1,81 +0,0 @@ -#include "BlobProperties.h" - - -/** -- FUNCIĶ: GetPerimeter -- FUNCIONALITAT: Get perimeter from chain code. Diagonals sum sqrt(2) and horizontal and vertical codes 1 -- PARĀMETRES: - - -- RESULTAT: - - -- RESTRICCIONS: - - -- AUTOR: rborras -- DATA DE CREACIĶ: 2008/04/30 -- MODIFICACIĶ: Data. Autor. Descripciķ. -- NOTA: Algorithm derived from "Methods to estimate area and perimeters of blob-like objects: A comparison", L.Yang -*/ -#define SQRT2 1.414213562 - -/** -- FUNCIĶ: GetPerimeter -- FUNCIONALITAT: Get blob area, ie. external contour area minus internal contours area -- PARĀMETRES: - - -- RESULTAT: - - -- RESTRICCIONS: - - -- AUTOR: rborras -- DATA DE CREACIĶ: 2008/04/30 -- MODIFICACIĶ: Data. Autor. Descripciķ. -*/ - -double CBlobProperties::GetArea() -{ - double area; - t_contourList::iterator itContour; - - area = m_externalContour.GetArea(); - - itContour = m_internalContours.begin(); - - while (itContour != m_internalContours.end() ) - { - area += (*itContour).GetArea(); - itContour++; - } - return area; -} - -/** -- FUNCIĶ: GetPerimeter -- FUNCIONALITAT: Get blob perimeter, ie. sum of the lenght of all the contours -- PARĀMETRES: - - -- RESULTAT: - - -- RESTRICCIONS: - - -- AUTOR: rborras -- DATA DE CREACIĶ: 2008/04/30 -- MODIFICACIĶ: Data. Autor. Descripciķ. -*/ -double CBlobProperties::GetPerimeter() -{ - double perimeter; - t_contourList::iterator itContour; - - perimeter = m_externalContour.GetPerimeter(); - - itContour = m_internalContours.begin(); - - while (itContour != m_internalContours.end() ) - { - perimeter += (*itContour).GetPerimeter(); - itContour++; - } - return perimeter; -} - - diff --git a/src/3rdparty/cvblobs/BlobProperties.h b/src/3rdparty/cvblobs/BlobProperties.h deleted file mode 100644 index e4afc6d0..00000000 --- a/src/3rdparty/cvblobs/BlobProperties.h +++ /dev/null @@ -1,70 +0,0 @@ - -//! Disable warnings referred to 255 character truncation for the std:map -#pragma warning( disable : 4786 ) - -#ifndef BLOB_PROPERTIES_H_INCLUDED -#define BLOB_PROPERTIES_H_INCLUDED - -#include -#include "BlobLibraryConfiguration.h" -#include "BlobContour.h" - - -#ifdef BLOB_OBJECT_FACTORY - //! Object factory pattern implementation - #include "..\inspecta\DesignPatterns\ObjectFactory.h" -#endif - - -//! Type of labelled images -typedef unsigned int t_labelType; - -//! Max order of calculated moments -#define MAX_MOMENTS_ORDER 3 - - -//! Blob class -class CBlobProperties -{ - typedef std::list t_contourList; - -public: - - CBlobProperties(); - virtual ~CBlobProperties(); - - //! Get blob area - double GetArea(); - - //! Get blob perimeter - double GetPerimeter(); - - //! Get contour moment (p,q up to MAX_CALCULATED_MOMENTS) - double GetMoment(int p, int q); - - - ////////////////////////////////////////////////////////////////////////// - // Blob contours - ////////////////////////////////////////////////////////////////////////// - - - //! Contour storage memory - CvMemStorage *m_storage; - //! External contour of the blob (crack codes) - CBlobContour m_externalContour; - //! Internal contours (crack codes) - t_contourList m_internalContours; - -private: - - //! Computed area from blob - double m_area; - //! Computed perimeter from blob - double m_perimeter; - // Computed moment from the blob - double m_moment[MAX_MOMENTS_ORDER*MAX_MOMENTS_ORDER]; - -}; - -#endif //!BLOB_PROPERTIES_H_INCLUDED - diff --git a/src/3rdparty/cvblobs/BlobResult.cpp b/src/3rdparty/cvblobs/BlobResult.cpp deleted file mode 100644 index 398ba8a8..00000000 --- a/src/3rdparty/cvblobs/BlobResult.cpp +++ /dev/null @@ -1,943 +0,0 @@ -/************************************************************************ - BlobResult.cpp - -FUNCIONALITAT: Implementaciķ de la classe CBlobResult -AUTOR: Inspecta S.L. -MODIFICACIONS (Modificaciķ, Autor, Data): - -**************************************************************************/ - -#include -#include -#include -#include -#include "BlobResult.h" - -//! Show errors functions: only works for windows releases -#ifdef _SHOW_ERRORS - #include //suport per a CStrings - #include //suport per a AfxMessageBox -#endif - -/************************************************************************** - Constructors / Destructors -**************************************************************************/ - - -/** -- FUNCIĶ: CBlobResult -- FUNCIONALITAT: Constructor estandard. -- PARĀMETRES: -- RESULTAT: -- Crea un CBlobResult sense cap blob -- RESTRICCIONS: -- AUTOR: Ricard Borrās -- DATA DE CREACIĶ: 20-07-2004. -- MODIFICACIĶ: Data. Autor. Descripciķ. -*/ -/** -- FUNCTION: CBlobResult -- FUNCTIONALITY: Standard constructor -- PARAMETERS: -- RESULT: - - creates an empty set of blobs -- RESTRICTIONS: -- AUTHOR: Ricard Borrās -- CREATION DATE: 25-05-2005. -- MODIFICATION: Date. Author. Description. -*/ -CBlobResult::CBlobResult() -{ - m_blobs = Blob_vector(); -} - -/** -- FUNCIĶ: CBlobResult -- FUNCIONALITAT: Constructor a partir d'una imatge. Inicialitza la seqüčncia de blobs - amb els blobs resultants de l'anālisi de blobs de la imatge. -- PARĀMETRES: - - source: imatge d'on s'extreuran els blobs - - mask: māscara a aplicar. Només es calcularan els blobs on la māscara sigui - diferent de 0. Els blobs que toquin a un pixel 0 de la māscara seran - considerats exteriors. - - threshold: llindar que s'aplicarā a la imatge source abans de calcular els blobs - - findmoments: indica si s'han de calcular els moments de cada blob - - blackBlobs: true per buscar blobs negres a la binaritzaziķ (it will join all extern white blobs). - false per buscar blobs negres a la binaritzaziķ (it will join all extern black blobs). - -- RESULTAT: - - objecte CBlobResult amb els blobs de la imatge source -- RESTRICCIONS: -- AUTOR: Ricard Borrās -- DATA DE CREACIĶ: 25-05-2005. -- MODIFICACIĶ: Data. Autor. Descripciķ. -*/ -/** -- FUNCTION: CBlob -- FUNCTIONALITY: Constructor from an image. Fills an object with all the blobs in - the image -- PARAMETERS: - - source: image to extract the blobs from - - mask: optional mask to apply. The blobs will be extracted where the mask is - not 0. All the neighbouring blobs where the mask is 0 will be extern blobs - - threshold: threshold level to apply to the image before computing blobs - - findmoments: true to calculate the blob moments (slower) (needed to calculate elipses!) - - blackBlobs: true to search for black blobs in the binarization (it will join all extern white blobs). - false to search for white blobs in the binarization (it will join all extern black blobs). -- RESULT: - - object with all the blobs in the image. It throws an EXCEPCIO_CALCUL_BLOBS - if some error appears in the BlobAnalysis function -- RESTRICTIONS: -- AUTHOR: Ricard Borrās -- CREATION DATE: 25-05-2005. -- MODIFICATION: Date. Author. Description. -*/ -CBlobResult::CBlobResult(IplImage *source, IplImage *mask, uchar backgroundColor ) -{ - bool success; - - try - { - success = ComponentLabeling( source, mask, backgroundColor, m_blobs ); - } - catch(...) - { - success = false; - } - - if( !success ) throw EXCEPCIO_CALCUL_BLOBS; -} - -/** -- FUNCIĶ: CBlobResult -- FUNCIONALITAT: Constructor de cōpia. Inicialitza la seqüčncia de blobs - amb els blobs del parāmetre. -- PARĀMETRES: - - source: objecte que es copiarā -- RESULTAT: - - objecte CBlobResult amb els blobs de l'objecte source -- RESTRICCIONS: -- AUTOR: Ricard Borrās -- DATA DE CREACIĶ: 25-05-2005. -- MODIFICACIĶ: Data. Autor. Descripciķ. -*/ -/** -- FUNCTION: CBlobResult -- FUNCTIONALITY: Copy constructor -- PARAMETERS: - - source: object to copy -- RESULT: -- RESTRICTIONS: -- AUTHOR: Ricard Borrās -- CREATION DATE: 25-05-2005. -- MODIFICATION: Date. Author. Description. -*/ -CBlobResult::CBlobResult( const CBlobResult &source ) -{ - m_blobs = Blob_vector( source.GetNumBlobs() ); - - // creem el nou a partir del passat com a parāmetre - m_blobs = Blob_vector( source.GetNumBlobs() ); - // copiem els blobs de l'origen a l'actual - Blob_vector::const_iterator pBlobsSrc = source.m_blobs.begin(); - Blob_vector::iterator pBlobsDst = m_blobs.begin(); - - while( pBlobsSrc != source.m_blobs.end() ) - { - // no podem cridar a l'operador = ja que Blob_vector és un - // vector de CBlob*. Per tant, creem un blob nou a partir del - // blob original - *pBlobsDst = new CBlob(**pBlobsSrc); - pBlobsSrc++; - pBlobsDst++; - } -} - - - -/** -- FUNCIĶ: ~CBlobResult -- FUNCIONALITAT: Destructor estandard. -- PARĀMETRES: -- RESULTAT: - - Allibera la memōria reservada de cadascun dels blobs de la classe -- RESTRICCIONS: -- AUTOR: Ricard Borrās -- DATA DE CREACIĶ: 25-05-2005. -- MODIFICACIĶ: Data. Autor. Descripciķ. -*/ -/** -- FUNCTION: ~CBlobResult -- FUNCTIONALITY: Destructor -- PARAMETERS: -- RESULT: -- RESTRICTIONS: -- AUTHOR: Ricard Borrās -- CREATION DATE: 25-05-2005. -- MODIFICATION: Date. Author. Description. -*/ -CBlobResult::~CBlobResult() -{ - ClearBlobs(); -} - -/************************************************************************** - Operadors / Operators -**************************************************************************/ - - -/** -- FUNCIĶ: operador = -- FUNCIONALITAT: Assigna un objecte source a l'actual -- PARĀMETRES: - - source: objecte a assignar -- RESULTAT: - - Substitueix els blobs actuals per els de l'objecte source -- RESTRICCIONS: -- AUTOR: Ricard Borrās -- DATA DE CREACIĶ: 25-05-2005. -- MODIFICACIĶ: Data. Autor. Descripciķ. -*/ -/** -- FUNCTION: Assigment operator -- FUNCTIONALITY: -- PARAMETERS: -- RESULT: -- RESTRICTIONS: -- AUTHOR: Ricard Borrās -- CREATION DATE: 25-05-2005. -- MODIFICATION: Date. Author. Description. -*/ -CBlobResult& CBlobResult::operator=(const CBlobResult& source) -{ - // si ja sķn el mateix, no cal fer res - if (this != &source) - { - // alliberem el conjunt de blobs antic - for( int i = 0; i < GetNumBlobs(); i++ ) - { - delete m_blobs[i]; - } - m_blobs.clear(); - // creem el nou a partir del passat com a parāmetre - m_blobs = Blob_vector( source.GetNumBlobs() ); - // copiem els blobs de l'origen a l'actual - Blob_vector::const_iterator pBlobsSrc = source.m_blobs.begin(); - Blob_vector::iterator pBlobsDst = m_blobs.begin(); - - while( pBlobsSrc != source.m_blobs.end() ) - { - // no podem cridar a l'operador = ja que Blob_vector és un - // vector de CBlob*. Per tant, creem un blob nou a partir del - // blob original - *pBlobsDst = new CBlob(**pBlobsSrc); - pBlobsSrc++; - pBlobsDst++; - } - } - return *this; -} - - -/** -- FUNCIĶ: operador + -- FUNCIONALITAT: Concatena els blobs de dos CBlobResult -- PARĀMETRES: - - source: d'on s'agafaran els blobs afegits a l'actual -- RESULTAT: - - retorna un nou CBlobResult amb els dos CBlobResult concatenats -- RESTRICCIONS: -- AUTOR: Ricard Borrās -- DATA DE CREACIĶ: 25-05-2005. -- NOTA: per la implementaciķ, els blobs del parāmetre es posen en ordre invers -- MODIFICACIĶ: Data. Autor. Descripciķ. -*/ -/** -- FUNCTION: + operator -- FUNCTIONALITY: Joins the blobs in source with the current ones -- PARAMETERS: - - source: object to copy the blobs -- RESULT: - - object with the actual blobs and the source blobs -- RESTRICTIONS: -- AUTHOR: Ricard Borrās -- CREATION DATE: 25-05-2005. -- MODIFICATION: Date. Author. Description. -*/ -CBlobResult CBlobResult::operator+( const CBlobResult& source ) const -{ - //creem el resultat a partir dels blobs actuals - CBlobResult resultat( *this ); - - // reservem memōria per als nous blobs - resultat.m_blobs.resize( resultat.GetNumBlobs() + source.GetNumBlobs() ); - - // declarem els iterador per recōrrer els blobs d'origen i desti - Blob_vector::const_iterator pBlobsSrc = source.m_blobs.begin(); - Blob_vector::iterator pBlobsDst = resultat.m_blobs.end(); - - // insertem els blobs de l'origen a l'actual - while( pBlobsSrc != source.m_blobs.end() ) - { - pBlobsDst--; - *pBlobsDst = new CBlob(**pBlobsSrc); - pBlobsSrc++; - } - - return resultat; -} - -/************************************************************************** - Operacions / Operations -**************************************************************************/ - -/** -- FUNCIĶ: AddBlob -- FUNCIONALITAT: Afegeix un blob al conjunt -- PARĀMETRES: - - blob: blob a afegir -- RESULTAT: - - modifica el conjunt de blobs actual -- RESTRICCIONS: -- AUTOR: Ricard Borrās -- DATA DE CREACIĶ: 2006/03/01 -- MODIFICACIĶ: Data. Autor. Descripciķ. -*/ -void CBlobResult::AddBlob( CBlob *blob ) -{ - if( blob != NULL ) - m_blobs.push_back( new CBlob( blob ) ); -} - - -#ifdef MATRIXCV_ACTIU - -/** -- FUNCIĶ: GetResult -- FUNCIONALITAT: Calcula el resultat especificat sobre tots els blobs de la classe -- PARĀMETRES: - - evaluador: Qualsevol objecte derivat de COperadorBlob -- RESULTAT: - - Retorna un array de double's amb el resultat per cada blob -- RESTRICCIONS: -- AUTOR: Ricard Borrās -- DATA DE CREACIĶ: 25-05-2005. -- MODIFICACIĶ: Data. Autor. Descripciķ. -*/ -/** -- FUNCTION: GetResult -- FUNCTIONALITY: Computes the function evaluador on all the blobs of the class - and returns a vector with the result -- PARAMETERS: - - evaluador: function to apply to each blob (any object derived from the - COperadorBlob class ) -- RESULT: - - vector with all the results in the same order as the blobs -- RESTRICTIONS: -- AUTHOR: Ricard Borrās -- CREATION DATE: 25-05-2005. -- MODIFICATION: Date. Author. Description. -*/ -double_vector CBlobResult::GetResult( funcio_calculBlob *evaluador ) const -{ - if( GetNumBlobs() <= 0 ) - { - return double_vector(); - } - - // definim el resultat - double_vector result = double_vector( GetNumBlobs() ); - // i iteradors sobre els blobs i el resultat - double_vector::iterator itResult = result.GetIterator(); - Blob_vector::const_iterator itBlobs = m_blobs.begin(); - - // avaluem la funciķ en tots els blobs - while( itBlobs != m_blobs.end() ) - { - *itResult = (*evaluador)(**itBlobs); - itBlobs++; - itResult++; - } - return result; -} -#endif - -/** -- FUNCIĶ: GetSTLResult -- FUNCIONALITAT: Calcula el resultat especificat sobre tots els blobs de la classe -- PARĀMETRES: - - evaluador: Qualsevol objecte derivat de COperadorBlob -- RESULTAT: - - Retorna un array de double's STL amb el resultat per cada blob -- RESTRICCIONS: -- AUTOR: Ricard Borrās -- DATA DE CREACIĶ: 25-05-2005. -- MODIFICACIĶ: Data. Autor. Descripciķ. -*/ -/** -- FUNCTION: GetResult -- FUNCTIONALITY: Computes the function evaluador on all the blobs of the class - and returns a vector with the result -- PARAMETERS: - - evaluador: function to apply to each blob (any object derived from the - COperadorBlob class ) -- RESULT: - - vector with all the results in the same order as the blobs -- RESTRICTIONS: -- AUTHOR: Ricard Borrās -- CREATION DATE: 25-05-2005. -- MODIFICATION: Date. Author. Description. -*/ -double_stl_vector CBlobResult::GetSTLResult( funcio_calculBlob *evaluador ) const -{ - if( GetNumBlobs() <= 0 ) - { - return double_stl_vector(); - } - - // definim el resultat - double_stl_vector result = double_stl_vector( GetNumBlobs() ); - // i iteradors sobre els blobs i el resultat - double_stl_vector::iterator itResult = result.begin(); - Blob_vector::const_iterator itBlobs = m_blobs.begin(); - - // avaluem la funciķ en tots els blobs - while( itBlobs != m_blobs.end() ) - { - *itResult = (*evaluador)(**itBlobs); - itBlobs++; - itResult++; - } - return result; -} - -/** -- FUNCIĶ: GetNumber -- FUNCIONALITAT: Calcula el resultat especificat sobre un únic blob de la classe -- PARĀMETRES: - - evaluador: Qualsevol objecte derivat de COperadorBlob - - indexblob: número de blob del que volem calcular el resultat. -- RESULTAT: - - Retorna un double amb el resultat -- RESTRICCIONS: -- AUTOR: Ricard Borrās -- DATA DE CREACIĶ: 25-05-2005. -- MODIFICACIĶ: Data. Autor. Descripciķ. -*/ -/** -- FUNCTION: GetNumber -- FUNCTIONALITY: Computes the function evaluador on a blob of the class -- PARAMETERS: - - indexBlob: index of the blob to compute the function - - evaluador: function to apply to each blob (any object derived from the - COperadorBlob class ) -- RESULT: -- RESTRICTIONS: -- AUTHOR: Ricard Borrās -- CREATION DATE: 25-05-2005. -- MODIFICATION: Date. Author. Description. -*/ -double CBlobResult::GetNumber( int indexBlob, funcio_calculBlob *evaluador ) const -{ - if( indexBlob < 0 || indexBlob >= GetNumBlobs() ) - RaiseError( EXCEPTION_BLOB_OUT_OF_BOUNDS ); - return (*evaluador)( *m_blobs[indexBlob] ); -} - -/////////////////////////// FILTRAT DE BLOBS //////////////////////////////////// - -/** -- FUNCIĶ: Filter -- FUNCIONALITAT: Filtra els blobs de la classe i deixa el resultat amb només - els blobs que han passat el filtre. - El filtrat es basa en especificar condicions sobre un resultat dels blobs - i seleccionar (o excloure) aquells blobs que no compleixen una determinada - condicio -- PARĀMETRES: - - dst: variable per deixar els blobs filtrats - - filterAction: acciķ de filtrat. Incloure els blobs trobats (B_INCLUDE), - o excloure els blobs trobats (B_EXCLUDE) - - evaluador: Funciķ per evaluar els blobs (qualsevol objecte derivat de COperadorBlob - - Condition: tipus de condiciķ que ha de superar la mesura (FilterType) - sobre cada blob per a ser considerat. - B_EQUAL,B_NOT_EQUAL,B_GREATER,B_LESS,B_GREATER_OR_EQUAL, - B_LESS_OR_EQUAL,B_INSIDE,B_OUTSIDE - - LowLimit: valor numčric per a la comparaciķ (Condition) de la mesura (FilterType) - - HighLimit: valor numčric per a la comparaciķ (Condition) de la mesura (FilterType) - (només té sentit per a aquelles condicions que tenen dos valors - (B_INSIDE, per exemple). -- RESULTAT: - - Deixa els blobs resultants del filtrat a destination -- RESTRICCIONS: -- AUTOR: Ricard Borrās -- DATA DE CREACIĶ: 25-05-2005. -- MODIFICACIĶ: Data. Autor. Descripciķ. -*/ -/** -- FUNCTION: Filter -- FUNCTIONALITY: Get some blobs from the class based on conditions on measures - of the blobs. -- PARAMETERS: - - dst: where to store the selected blobs - - filterAction: B_INCLUDE: include the blobs which pass the filter in the result - B_EXCLUDE: exclude the blobs which pass the filter in the result - - evaluador: Object to evaluate the blob - - Condition: How to decide if the result returned by evaluador on each blob - is included or not. It can be: - B_EQUAL,B_NOT_EQUAL,B_GREATER,B_LESS,B_GREATER_OR_EQUAL, - B_LESS_OR_EQUAL,B_INSIDE,B_OUTSIDE - - LowLimit: numerical value to evaluate the Condition on evaluador(blob) - - HighLimit: numerical value to evaluate the Condition on evaluador(blob). - Only useful for B_INSIDE and B_OUTSIDE -- RESULT: - - It returns on dst the blobs that accomplish (B_INCLUDE) or discards (B_EXCLUDE) - the Condition on the result returned by evaluador on each blob -- RESTRICTIONS: -- AUTHOR: Ricard Borrās -- CREATION DATE: 25-05-2005. -- MODIFICATION: Date. Author. Description. -*/ -void CBlobResult::Filter(CBlobResult &dst, - int filterAction, - funcio_calculBlob *evaluador, - int condition, - double lowLimit, double highLimit /*=0*/) const - -{ - // do the job - DoFilter(dst, filterAction, evaluador, condition, lowLimit, highLimit ); -} - -/** -- FUNCIĶ: Filter (const version) -- FUNCIONALITAT: Filtra els blobs de la classe i deixa el resultat amb només - els blobs que han passat el filtre. - El filtrat es basa en especificar condicions sobre un resultat dels blobs - i seleccionar (o excloure) aquells blobs que no compleixen una determinada - condicio -- PARĀMETRES: - - dst: variable per deixar els blobs filtrats - - filterAction: acciķ de filtrat. Incloure els blobs trobats (B_INCLUDE), - o excloure els blobs trobats (B_EXCLUDE) - - evaluador: Funciķ per evaluar els blobs (qualsevol objecte derivat de COperadorBlob - - Condition: tipus de condiciķ que ha de superar la mesura (FilterType) - sobre cada blob per a ser considerat. - B_EQUAL,B_NOT_EQUAL,B_GREATER,B_LESS,B_GREATER_OR_EQUAL, - B_LESS_OR_EQUAL,B_INSIDE,B_OUTSIDE - - LowLimit: valor numčric per a la comparaciķ (Condition) de la mesura (FilterType) - - HighLimit: valor numčric per a la comparaciķ (Condition) de la mesura (FilterType) - (només té sentit per a aquelles condicions que tenen dos valors - (B_INSIDE, per exemple). -- RESULTAT: - - Deixa els blobs resultants del filtrat a destination -- RESTRICCIONS: -- AUTOR: Ricard Borrās -- DATA DE CREACIĶ: 25-05-2005. -- MODIFICACIĶ: Data. Autor. Descripciķ. -*/ -/** -- FUNCTION: Filter (const version) -- FUNCTIONALITY: Get some blobs from the class based on conditions on measures - of the blobs. -- PARAMETERS: - - dst: where to store the selected blobs - - filterAction: B_INCLUDE: include the blobs which pass the filter in the result - B_EXCLUDE: exclude the blobs which pass the filter in the result - - evaluador: Object to evaluate the blob - - Condition: How to decide if the result returned by evaluador on each blob - is included or not. It can be: - B_EQUAL,B_NOT_EQUAL,B_GREATER,B_LESS,B_GREATER_OR_EQUAL, - B_LESS_OR_EQUAL,B_INSIDE,B_OUTSIDE - - LowLimit: numerical value to evaluate the Condition on evaluador(blob) - - HighLimit: numerical value to evaluate the Condition on evaluador(blob). - Only useful for B_INSIDE and B_OUTSIDE -- RESULT: - - It returns on dst the blobs that accomplish (B_INCLUDE) or discards (B_EXCLUDE) - the Condition on the result returned by evaluador on each blob -- RESTRICTIONS: -- AUTHOR: Ricard Borrās -- CREATION DATE: 25-05-2005. -- MODIFICATION: Date. Author. Description. -*/ -void CBlobResult::Filter(CBlobResult &dst, - int filterAction, - funcio_calculBlob *evaluador, - int condition, - double lowLimit, double highLimit /*=0*/) - -{ - int numBlobs = GetNumBlobs(); - - // do the job - DoFilter(dst, filterAction, evaluador, condition, lowLimit, highLimit ); - - // inline operation: remove previous blobs - if( &dst == this ) - { - // esborrem els primers blobs ( que sķn els originals ) - // ja que els tindrem replicats al final si passen el filtre - Blob_vector::iterator itBlobs = m_blobs.begin(); - for( int i = 0; i < numBlobs; i++ ) - { - delete *itBlobs; - itBlobs++; - } - m_blobs.erase( m_blobs.begin(), itBlobs ); - } -} - - -//! Does the Filter method job -void CBlobResult::DoFilter(CBlobResult &dst, int filterAction, funcio_calculBlob *evaluador, - int condition, double lowLimit, double highLimit/* = 0*/) const -{ - int i, numBlobs; - bool resultavaluacio; - double_stl_vector avaluacioBlobs; - double_stl_vector::iterator itavaluacioBlobs; - - if( GetNumBlobs() <= 0 ) return; - if( !evaluador ) return; - //avaluem els blobs amb la funciķ pertinent - avaluacioBlobs = GetSTLResult(evaluador); - itavaluacioBlobs = avaluacioBlobs.begin(); - numBlobs = GetNumBlobs(); - switch(condition) - { - case B_EQUAL: - for(i=0;i lowLimit; - if( ( resultavaluacio && filterAction == B_INCLUDE ) || - ( !resultavaluacio && filterAction == B_EXCLUDE )) - { - dst.m_blobs.push_back( new CBlob( GetBlob( i ) )); - } - } - break; - case B_LESS: - for(i=0;i= lowLimit; - if( ( resultavaluacio && filterAction == B_INCLUDE ) || - ( !resultavaluacio && filterAction == B_EXCLUDE )) - { - dst.m_blobs.push_back( new CBlob( GetBlob( i ) )); - } - } - break; - case B_LESS_OR_EQUAL: - for(i=0;i= lowLimit) && ( *itavaluacioBlobs <= highLimit); - if( ( resultavaluacio && filterAction == B_INCLUDE ) || - ( !resultavaluacio && filterAction == B_EXCLUDE )) - { - dst.m_blobs.push_back( new CBlob( GetBlob( i ) )); - } - } - break; - case B_OUTSIDE: - for(i=0;i highLimit); - if( ( resultavaluacio && filterAction == B_INCLUDE ) || - ( !resultavaluacio && filterAction == B_EXCLUDE )) - { - dst.m_blobs.push_back( new CBlob( GetBlob( i ) )); - } - } - break; - } -} -/** -- FUNCIĶ: GetBlob -- FUNCIONALITAT: Retorna un blob si aquest existeix (index != -1) -- PARĀMETRES: - - indexblob: index del blob a retornar -- RESULTAT: -- RESTRICCIONS: -- AUTOR: Ricard Borrās -- DATA DE CREACIĶ: 25-05-2005. -- MODIFICACIĶ: Data. Autor. Descripciķ. -*/ -/* -- FUNCTION: GetBlob -- FUNCTIONALITY: Gets the n-th blob (without ordering the blobs) -- PARAMETERS: - - indexblob: index in the blob array -- RESULT: -- RESTRICTIONS: -- AUTHOR: Ricard Borrās -- CREATION DATE: 25-05-2005. -- MODIFICATION: Date. Author. Description. -*/ -CBlob CBlobResult::GetBlob(int indexblob) const -{ - if( indexblob < 0 || indexblob >= GetNumBlobs() ) - RaiseError( EXCEPTION_BLOB_OUT_OF_BOUNDS ); - - return *m_blobs[indexblob]; -} -CBlob *CBlobResult::GetBlob(int indexblob) -{ - if( indexblob < 0 || indexblob >= GetNumBlobs() ) - RaiseError( EXCEPTION_BLOB_OUT_OF_BOUNDS ); - - return m_blobs[indexblob]; -} - -/** -- FUNCIĶ: GetNthBlob -- FUNCIONALITAT: Retorna l'enčssim blob segons un determinat criteri -- PARĀMETRES: - - criteri: criteri per ordenar els blobs (objectes derivats de COperadorBlob) - - nBlob: index del blob a retornar - - dst: on es retorna el resultat -- RESULTAT: - - retorna el blob nBlob a dst ordenant els blobs de la classe segons el criteri - en ordre DESCENDENT. Per exemple, per obtenir el blob major: - GetNthBlob( CBlobGetArea(), 0, blobMajor ); - GetNthBlob( CBlobGetArea(), 1, blobMajor ); (segon blob més gran) -- RESTRICCIONS: -- AUTOR: Ricard Borrās -- DATA DE CREACIĶ: 25-05-2005. -- MODIFICACIĶ: Data. Autor. Descripciķ. -*/ -/* -- FUNCTION: GetNthBlob -- FUNCTIONALITY: Gets the n-th blob ordering first the blobs with some criteria -- PARAMETERS: - - criteri: criteria to order the blob array - - nBlob: index of the returned blob in the ordered blob array - - dst: where to store the result -- RESULT: -- RESTRICTIONS: -- AUTHOR: Ricard Borrās -- CREATION DATE: 25-05-2005. -- MODIFICATION: Date. Author. Description. -*/ -void CBlobResult::GetNthBlob( funcio_calculBlob *criteri, int nBlob, CBlob &dst ) const -{ - // verifiquem que no estem accedint fora el vector de blobs - if( nBlob < 0 || nBlob >= GetNumBlobs() ) - { - //RaiseError( EXCEPTION_BLOB_OUT_OF_BOUNDS ); - dst = CBlob(); - return; - } - - double_stl_vector avaluacioBlobs, avaluacioBlobsOrdenat; - double valorEnessim; - - //avaluem els blobs amb la funciķ pertinent - avaluacioBlobs = GetSTLResult(criteri); - - avaluacioBlobsOrdenat = double_stl_vector( GetNumBlobs() ); - - // obtenim els nBlob primers resultats (en ordre descendent) - std::partial_sort_copy( avaluacioBlobs.begin(), - avaluacioBlobs.end(), - avaluacioBlobsOrdenat.begin(), - avaluacioBlobsOrdenat.end(), - std::greater() ); - - valorEnessim = avaluacioBlobsOrdenat[nBlob]; - - // busquem el primer blob que té el valor n-ssim - double_stl_vector::const_iterator itAvaluacio = avaluacioBlobs.begin(); - - bool trobatBlob = false; - int indexBlob = 0; - while( itAvaluacio != avaluacioBlobs.end() && !trobatBlob ) - { - if( *itAvaluacio == valorEnessim ) - { - trobatBlob = true; - dst = CBlob( GetBlob(indexBlob)); - } - itAvaluacio++; - indexBlob++; - } -} - -/** -- FUNCIĶ: ClearBlobs -- FUNCIONALITAT: Elimina tots els blobs de l'objecte -- PARĀMETRES: -- RESULTAT: - - Allibera tota la memōria dels blobs -- RESTRICCIONS: -- AUTOR: Ricard Borrās Navarra -- DATA DE CREACIĶ: 25-05-2005. -- MODIFICACIĶ: Data. Autor. Descripciķ. -*/ -/* -- FUNCTION: ClearBlobs -- FUNCTIONALITY: Clears all the blobs from the object and releases all its memory -- PARAMETERS: -- RESULT: -- RESTRICTIONS: -- AUTHOR: Ricard Borrās -- CREATION DATE: 25-05-2005. -- MODIFICATION: Date. Author. Description. -*/ -void CBlobResult::ClearBlobs() -{ - Blob_vector::iterator itBlobs = m_blobs.begin(); - while( itBlobs != m_blobs.end() ) - { - delete *itBlobs; - itBlobs++; - } - - m_blobs.clear(); -} - -/** -- FUNCIĶ: RaiseError -- FUNCIONALITAT: Funciķ per a notificar errors al l'usuari (en debug) i llenįa - les excepcions -- PARĀMETRES: - - errorCode: codi d'error -- RESULTAT: - - Ensenya un missatge a l'usuari (en debug) i llenįa una excepciķ -- RESTRICCIONS: -- AUTOR: Ricard Borrās Navarra -- DATA DE CREACIĶ: 25-05-2005. -- MODIFICACIĶ: Data. Autor. Descripciķ. -*/ -/* -- FUNCTION: RaiseError -- FUNCTIONALITY: Error handling function -- PARAMETERS: - - errorCode: reason of the error -- RESULT: - - in _SHOW_ERRORS version, shows a message box with the error. In release is silent. - In both cases throws an exception with the error. -- RESTRICTIONS: -- AUTHOR: Ricard Borrās -- CREATION DATE: 25-05-2005. -- MODIFICATION: Date. Author. Description. -*/ -void CBlobResult::RaiseError(const int errorCode) const -{ -//! Do we need to show errors? -#ifdef _SHOW_ERRORS - CString msg, format = "Error en CBlobResult: %s"; - - switch (errorCode) - { - case EXCEPTION_BLOB_OUT_OF_BOUNDS: - msg.Format(format, "Intentant accedir a un blob no existent"); - break; - default: - msg.Format(format, "Codi d'error desconegut"); - break; - } - - AfxMessageBox(msg); - -#endif - throw errorCode; -} - - - -/************************************************************************** - Auxiliars / Auxiliary functions -**************************************************************************/ - - -/** -- FUNCIĶ: PrintBlobs -- FUNCIONALITAT: Escriu els parāmetres (ārea, perímetre, exterior, mitjana) - de tots els blobs a un fitxer. -- PARĀMETRES: - - nom_fitxer: path complet del fitxer amb el resultat -- RESULTAT: -- RESTRICCIONS: -- AUTOR: Ricard Borrās -- DATA DE CREACIĶ: 25-05-2005. -- MODIFICACIĶ: Data. Autor. Descripciķ. -*/ -/* -- FUNCTION: PrintBlobs -- FUNCTIONALITY: Prints some blob features in an ASCII file -- PARAMETERS: - - nom_fitxer: full path + filename to generate -- RESULT: -- RESTRICTIONS: -- AUTHOR: Ricard Borrās -- CREATION DATE: 25-05-2005. -- MODIFICATION: Date. Author. Description. -*/ -void CBlobResult::PrintBlobs( char *nom_fitxer ) const -{ - double_stl_vector area, /*perimetre,*/ exterior, compacitat, longitud, - externPerimeter, perimetreConvex, perimetre; - int i; - FILE *fitxer_sortida; - - area = GetSTLResult( CBlobGetArea()); - perimetre = GetSTLResult( CBlobGetPerimeter()); - exterior = GetSTLResult( CBlobGetExterior()); - compacitat = GetSTLResult(CBlobGetCompactness()); - longitud = GetSTLResult( CBlobGetLength()); - externPerimeter = GetSTLResult( CBlobGetExternPerimeter()); - perimetreConvex = GetSTLResult( CBlobGetHullPerimeter()); - - fitxer_sortida = fopen( nom_fitxer, "w" ); - - for(i=0; i\t a=%7.0f\t p=%8.2f (%8.2f extern)\t pconvex=%8.2f\t ext=%.0f\t m=%7.2f\t c=%3.2f\t l=%8.2f\n", - i, area[i], perimetre[i], externPerimeter[i], perimetreConvex[i], exterior[i], compacitat[i], longitud[i] ); - } - fclose( fitxer_sortida ); - -} diff --git a/src/3rdparty/cvblobs/BlobResult.h b/src/3rdparty/cvblobs/BlobResult.h deleted file mode 100644 index e437a976..00000000 --- a/src/3rdparty/cvblobs/BlobResult.h +++ /dev/null @@ -1,171 +0,0 @@ -/************************************************************************ - BlobResult.h - -FUNCIONALITAT: DefiniciīŋŊ de la classe CBlobResult -AUTOR: Inspecta S.L. -MODIFICACIONS (ModificaciīŋŊ, Autor, Data): - -FUNCTIONALITY: Definition of the CBlobResult class -AUTHOR: Inspecta S.L. -MODIFICATIONS (Modification, Author, Date): - -**************************************************************************/ - - -#if !defined(_CLASSE_BLOBRESULT_INCLUDED) -#define _CLASSE_BLOBRESULT_INCLUDED - -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 - -#include "BlobLibraryConfiguration.h" -#include -#include - -#ifdef MATRIXCV_ACTIU - #include "matrixCV.h" -#else - // llibreria STL - #include "vector" - //! Vector de doubles - typedef std::vector double_stl_vector; -#endif - -#include // vectors de la STL -#include -#include "blob.h" -#include "BlobOperators.h" -#include "ComponentLabeling.h" -/************************************************************************** - Filtres / Filters -**************************************************************************/ - -//! accions que es poden fer amb els filtres -//! Actions performed by a filter (include or exclude blobs) -#define B_INCLUDE 1L -#define B_EXCLUDE 2L - -//! condicions sobre els filtres -//! Conditions to apply the filters -#define B_EQUAL 3L -#define B_NOT_EQUAL 4L -#define B_GREATER 5L -#define B_LESS 6L -#define B_GREATER_OR_EQUAL 7L -#define B_LESS_OR_EQUAL 8L -#define B_INSIDE 9L -#define B_OUTSIDE 10L - - -/************************************************************************** - Excepcions / Exceptions -**************************************************************************/ - -//! Excepcions llenīŋŊades per les funcions: -#define EXCEPTION_BLOB_OUT_OF_BOUNDS 1000 -#define EXCEPCIO_CALCUL_BLOBS 1001 - -/** - Classe que contīŋŊ un conjunt de blobs i permet extreure'n propietats - o filtrar-los segons determinats criteris. - Class to calculate the blobs of an image and calculate some properties - on them. Also, the class provides functions to filter the blobs using - some criteria. -*/ -class CBlobResult -{ -public: - - //! constructor estandard, crea un conjunt buit de blobs - //! Standard constructor, it creates an empty set of blobs - CBlobResult(); - //! constructor a partir d'una imatge - //! Image constructor, it creates an object with the blobs of the image - CBlobResult(IplImage *source, IplImage *mask, uchar backgroundColor); - //! constructor de cīŋŊpia - //! Copy constructor - CBlobResult( const CBlobResult &source ); - //! Destructor - virtual ~CBlobResult(); - - //! operador = per a fer assignacions entre CBlobResult - //! Assigment operator - CBlobResult& operator=(const CBlobResult& source); - //! operador + per concatenar dos CBlobResult - //! Addition operator to concatenate two sets of blobs - CBlobResult operator+( const CBlobResult& source ) const; - - //! Afegeix un blob al conjunt - //! Adds a blob to the set of blobs - void AddBlob( CBlob *blob ); - -#ifdef MATRIXCV_ACTIU - //! Calcula un valor sobre tots els blobs de la classe retornant una MatrixCV - //! Computes some property on all the blobs of the class - double_vector GetResult( funcio_calculBlob *evaluador ) const; -#endif - //! Calcula un valor sobre tots els blobs de la classe retornant un std::vector - //! Computes some property on all the blobs of the class - double_stl_vector GetSTLResult( funcio_calculBlob *evaluador ) const; - - //! Calcula un valor sobre un blob de la classe - //! Computes some property on one blob of the class - double GetNumber( int indexblob, funcio_calculBlob *evaluador ) const; - - //! Retorna aquells blobs que compleixen les condicions del filtre en el destination - //! Filters the blobs of the class using some property - void Filter(CBlobResult &dst, - int filterAction, funcio_calculBlob *evaluador, - int condition, double lowLimit, double highLimit = 0 ); - void Filter(CBlobResult &dst, - int filterAction, funcio_calculBlob *evaluador, - int condition, double lowLimit, double highLimit = 0 ) const; - - //! Retorna l'enīŋŊssim blob segons un determinat criteri - //! Sorts the blobs of the class acording to some criteria and returns the n-th blob - void GetNthBlob( funcio_calculBlob *criteri, int nBlob, CBlob &dst ) const; - - //! Retorna el blob enīŋŊssim - //! Gets the n-th blob of the class ( without sorting ) - CBlob GetBlob(int indexblob) const; - CBlob *GetBlob(int indexblob); - - //! Elimina tots els blobs de l'objecte - //! Clears all the blobs of the class - void ClearBlobs(); - - //! Escriu els blobs a un fitxer - //! Prints some features of all the blobs in a file - void PrintBlobs( char *nom_fitxer ) const; - - -//Metodes GET/SET - - //! Retorna el total de blobs - //! Gets the total number of blobs - int GetNumBlobs() const - { - return(m_blobs.size()); - } - - -private: - - //! FunciīŋŊ per gestionar els errors - //! Function to manage the errors - void RaiseError(const int errorCode) const; - - //! Does the Filter method job - void DoFilter(CBlobResult &dst, - int filterAction, funcio_calculBlob *evaluador, - int condition, double lowLimit, double highLimit = 0) const; - -protected: - - //! Vector amb els blobs - //! Vector with all the blobs - Blob_vector m_blobs; -}; - -#endif // !defined(_CLASSE_BLOBRESULT_INCLUDED) diff --git a/src/3rdparty/cvblobs/CMakeLists.txt b/src/3rdparty/cvblobs/CMakeLists.txt deleted file mode 100644 index 2f46f780..00000000 --- a/src/3rdparty/cvblobs/CMakeLists.txt +++ /dev/null @@ -1,15 +0,0 @@ -add_library(cvblobs - blob.cpp - BlobContour.cpp - BlobOperators.cpp - BlobProperties.cpp - BlobResult.cpp - ComponentLabeling.cpp - blob.h - BlobContour.h - BlobLibraryConfiguration.h - BlobOperators.h - BlobProperties.h - BlobResult.h - ComponentLabeling.h) - diff --git a/src/3rdparty/cvblobs/ComponentLabeling.cpp b/src/3rdparty/cvblobs/ComponentLabeling.cpp deleted file mode 100644 index 2e4a2147..00000000 --- a/src/3rdparty/cvblobs/ComponentLabeling.cpp +++ /dev/null @@ -1,406 +0,0 @@ - -#include "ComponentLabeling.h" - -//! Conversion from freeman code to coordinate increments (counterclockwise) -static const CvPoint freemanCodeIncrement[8] = - { {1, 0}, {1, -1}, {0, -1}, {-1, -1}, {-1, 0}, {-1, 1}, {0, 1}, {1, 1} }; - - - -/** -- FUNCIĶ: -- FUNCIONALITAT: -- PARĀMETRES: - - -- RESULTAT: - - -- RESTRICCIONS: - - -- AUTOR: rborras -- DATA DE CREACIĶ: 2008/04/29 -- MODIFICACIĶ: Data. Autor. Descripciķ. -*/ -inline unsigned char GET_ABOVE_IMAGEPIXEL( unsigned char *currentPixel, IplImage *image ) -{ - return *(currentPixel - image->widthStep); -} -inline unsigned char GET_BELOW_IMAGEPIXEL( unsigned char *currentPixel, IplImage *image ) -{ - return *(currentPixel + image->widthStep); -} - - - -inline unsigned char GET_IMAGE_PIXEL( IplImage *image, CvPoint p ) -{ - return *(image->imageData + p.x + p.y *image->widthStep); -} - -inline bool GET_IMAGEMASK_PIXEL( IplImage *mask, CvPoint p ) -{ - if( mask != NULL ) - return ((unsigned char)*(mask->imageData + p.x + p.y *mask->widthStep)) > 0; - else - return true; -} -inline bool GET_BELOW_VISITEDPIXEL( bool *currentPixel, int imageWidth ) -{ - return *( currentPixel + imageWidth ); -} - -/** -- FUNCIĶ: ASSIGN_LABEL -- FUNCIONALITAT: Assigns label value to label image -- PARĀMETRES: - - -- RESULTAT: - - -- RESTRICCIONS: - - -- AUTOR: rborras -- DATA DE CREACIĶ: 2008/04/29 -- MODIFICACIĶ: Data. Autor. Descripciķ. -*/ -inline void ASSIGN_LABEL( CvPoint p, t_labelType *labels, int imageWidth, int newLabel ) -{ - *(labels + p.y * imageWidth + p.x) = newLabel; -} - - -inline void ASSIGN_VISITED( CvPoint p, bool *visitedPoints, int imageWidth ) -{ - *(visitedPoints + p.y * imageWidth + p.x) = true; -} - -/** -- FUNCIĶ: ComponentLabeling -- FUNCIONALITAT: Calcula els components binaris (blobs) d'una imatge amb connectivitat a 8 -- PARĀMETRES: - - inputImage: image to segment (pixel values different than blobColor are treated as background) - - maskImage: if not NULL, all the pixels equal to 0 in mask are skipped in input image - - backgroundColor: color of background (ignored pixels) - - blobs: blob vector destination -- RESULTAT: - - -- RESTRICCIONS: - - -- AUTOR: rborras -- DATA DE CREACIĶ: 2008/04/21 -- MODIFICACIĶ: Data. Autor. Descripciķ. -- NOTA: Algorithm based on "A linear-time component labeling algorithm using contour tracing technique", - F.Chang et al -*/ -bool ComponentLabeling( IplImage* inputImage, - IplImage* maskImage, - unsigned char backgroundColor, - Blob_vector &blobs ) -{ - int i,j; - // row major vector with visited points - bool *visitedPoints, *pVisitedPoints, internalContour, externalContour; - unsigned char *pInputImage, *pMask, *pAboveInputImage, *pBelowInputImage, - *pAboveMask, *pBelowMask; - int imageWidth, imageHeight, currentLabel, contourLabel; - // row major vector with labelled image - t_labelType *labelledImage, *pLabels; - //! current blob pointer - CBlob *currentBlob; - CvSize imageSizes; - CvPoint currentPoint; - - // verify input image - if( !CV_IS_IMAGE( inputImage ) ) - return false; - - // verify that input image and mask image has same size - if( maskImage ) - { - if( !CV_IS_IMAGE(maskImage) || - maskImage->width != inputImage->width || - maskImage->height != inputImage->height ) - return false; - } - else - { - pMask = NULL; - pAboveMask = NULL; - pBelowMask = NULL; - } - - imageSizes = cvSize(inputImage->width,inputImage->height); - - imageWidth = inputImage->width; - imageHeight = inputImage->height; - - // create auxiliary buffers - labelledImage = (t_labelType*) malloc( inputImage->width * inputImage->height * sizeof(t_labelType) ); - visitedPoints = (bool*) malloc( inputImage->width * inputImage->height * sizeof(bool) ); - - // initialize it to 0 - memset(labelledImage, 0, inputImage->width * inputImage->height * sizeof(t_labelType) ) ; - memset(visitedPoints, false, inputImage->width * inputImage->height * sizeof(bool) ) ; - - // initialize pointers and label counter - pLabels = labelledImage; - pVisitedPoints = visitedPoints; - currentLabel = 1; - - for (j = 0; j < imageHeight; j++ ) - { - // don't verify if we area on first or last row, it will verified on pointer access - pAboveInputImage = (unsigned char*) inputImage->imageData + (j-1) * inputImage->widthStep; - pBelowInputImage = (unsigned char*) inputImage->imageData + (j+1) * inputImage->widthStep; - - pInputImage = (unsigned char*) inputImage->imageData + j * inputImage->widthStep; - - if( maskImage ) - { - pMask = (unsigned char*) maskImage->imageData + j * maskImage->widthStep; - // don't verify if we area on first or last row, it will verified on pointer access - pAboveMask = (unsigned char*) maskImage->imageData + (j-1) * maskImage->widthStep; - pBelowMask = (unsigned char*) maskImage->imageData + (j+1) * maskImage->widthStep; - - } - - for (i = 0; i < imageWidth; i++, pInputImage++, pMask++, pAboveInputImage++, pBelowInputImage++, - pAboveMask++, pBelowMask++ ) - { - // ignore background pixels or 0 pixels in mask - if ( (*pInputImage == backgroundColor) || (maskImage && *pMask == 0 )) - { - pLabels++; - pVisitedPoints++; - continue; - } - - // new external contour: current label == 0 and above pixel is background - if( j > 0 ) - { - externalContour = ((*pAboveInputImage == backgroundColor) || - (maskImage && *pAboveMask == 0)) && - (*pLabels == 0); - } - else - externalContour = (*pLabels == 0); - - // new internal contour: below pixel is background and not visited - if( !externalContour && j < imageHeight - 1 ) - { - internalContour = *pBelowInputImage == backgroundColor && - !GET_BELOW_VISITEDPIXEL( pVisitedPoints, imageWidth); - } - else - { - internalContour = false; - } - - - if( externalContour ) - { - currentPoint = cvPoint(i,j); - // assign label to labelled image - *pLabels = currentLabel; - - // create new blob - currentBlob = new CBlob(currentLabel, currentPoint, imageSizes ); - - // contour tracing with currentLabel - contourTracing( inputImage, maskImage, currentPoint, - labelledImage, visitedPoints, - currentLabel, false, backgroundColor, currentBlob->GetExternalContour() ); - - // add new created blob - blobs.push_back(currentBlob); - - currentLabel++; - } - else - { - if( internalContour ) - { - currentPoint = cvPoint(i,j); - - if( *pLabels == 0 ) - { - // take left neightbour value as current - if( i > 0 ) - contourLabel = *(pLabels - 1); - } - else - { - contourLabel = *pLabels; - } - - if(contourLabel>0) - { - currentBlob = blobs[contourLabel-1]; - CBlobContour newContour(currentPoint, currentBlob->GetStorage()); - - - // contour tracing with contourLabel - contourTracing( inputImage, maskImage, currentPoint, labelledImage, visitedPoints, - contourLabel, true, backgroundColor, &newContour ); - - currentBlob->AddInternalContour( newContour ); - } - } - // neither internal nor external contour - else - { - // take left neightbour value as current if it is not labelled - if( i > 0 && *pLabels == 0 ) - *pLabels = *(pLabels - 1); - } - - } - - pLabels++; - pVisitedPoints++; - - } - } - - - // free auxiliary buffers - free( labelledImage ); - free( visitedPoints ); - - return true; -} - - - -/** -- FUNCIĶ: -- FUNCIONALITAT: -- PARĀMETRES: - - -- RESULTAT: - - -- RESTRICCIONS: - - -- AUTOR: rborras -- DATA DE CREACIĶ: 2008/04/29 -- MODIFICACIĶ: Data. Autor. Descripciķ. -*/ -void contourTracing( IplImage *image, - IplImage *maskImage, - CvPoint contourStart, t_labelType *labels, bool *visitedPoints, t_labelType label, - bool internalContour, unsigned char backgroundColor, CBlobContour *currentBlobcontour ) -{ - CvPoint t, tnext, tsecond; - short initialMovement, movement; - - if( internalContour ) - { - initialMovement = 7;//3; - } - else - { - initialMovement = 3;//7; - } - - tsecond = tracer( image, maskImage, contourStart, visitedPoints, initialMovement, - backgroundColor, movement ); - - // assign current label to tnext - ASSIGN_LABEL( contourStart, labels, image->width, label ); - - - // contour corresponds to isolated pixel? - if( tsecond.x == contourStart.x && tsecond.y == contourStart.y ) - { - // we are finished with the contour - return; - } - - // add chain code to current contour - currentBlobcontour->AddChainCode(movement); - - // assign label to next point - ASSIGN_LABEL( tsecond, labels, image->width, label ); - - tnext.x = tsecond.x; - tnext.y = tsecond.y; - t.x = tnext.x; - t.y = tnext.y; - - // while T is different than contourStart and Tnext is different than T - // follow contour until start point is reached again - while ( t.x != contourStart.x || t.y != contourStart.y || - tsecond.x != tnext.x || tsecond.y != tnext.y ) - { - - t.x = tnext.x; - t.y = tnext.y; - initialMovement = (movement + 5) % 8; - - // search for next contour point - tnext = tracer( image, maskImage, t, visitedPoints, initialMovement, - backgroundColor, movement ); - - // assign label to contour point - ASSIGN_LABEL( tnext, labels, image->width, label ); - - // add chain code to current contour - currentBlobcontour->AddChainCode(movement); - } - -} - -/** -- FUNCIĶ: tracer -- FUNCIONALITAT: Searches for next point of a contour -- PARĀMETRES: - - -- RESULTAT: - - -- RESTRICCIONS: - - -- AUTOR: rborras -- DATA DE CREACIĶ: 2008/04/30 -- MODIFICACIĶ: Data. Autor. Descripciķ. -*/ -CvPoint tracer( IplImage *image, IplImage *maskImage, CvPoint P, bool *visitedPoints, - short initialMovement, - unsigned char backgroundColor, short &movement ) -{ - int d; - CvPoint pNext; - - for (d = 0; d <= 7; d++ ) - { - movement = (initialMovement + d) % 8; - - pNext.x = P.x + freemanCodeIncrement[movement].x; - pNext.y = P.y + freemanCodeIncrement[movement].y; - - // the point is inside image ? - if( pNext.x < 0 || pNext.x >= image->width || - pNext.y < 0 || pNext.y >= image->height ) - { - // try other movement - continue; - } - - // image has blobColor value in the new point? - if( (GET_IMAGE_PIXEL( image, pNext ) != backgroundColor ) && GET_IMAGEMASK_PIXEL(maskImage, pNext ) ) - { - return pNext; - } - else - { - // mark point as visited - ASSIGN_VISITED( pNext, visitedPoints, image->width ); - } - } - - // no possible movement was found - movement = -1; - pNext.x = P.x; - pNext.y = P.y; - - return pNext; -} - - diff --git a/src/3rdparty/cvblobs/ComponentLabeling.h b/src/3rdparty/cvblobs/ComponentLabeling.h deleted file mode 100644 index 592c21e9..00000000 --- a/src/3rdparty/cvblobs/ComponentLabeling.h +++ /dev/null @@ -1,30 +0,0 @@ -#if !defined(_COMPONENT_LABELING_H_INCLUDED) -#define _CLASSE_BLOBRESULT_INCLUDED - -#include "vector" -#include "BlobContour.h" -#include "blob.h" - - -//! definiciķ de que es un vector de blobs -typedef std::vector Blob_vector; - - - -bool ComponentLabeling( IplImage* inputImage, - IplImage* maskImage, - unsigned char backgroundColor, - Blob_vector &blobs ); - - -void contourTracing( IplImage *image, IplImage *mask, CvPoint contourStart, t_labelType *labels, - bool *visitedPoints, t_labelType label, - bool internalContour, unsigned char backgroundColor, - CBlobContour *currentBlobContour ); - -CvPoint tracer( IplImage *image, IplImage *mask, CvPoint P, bool *visitedPoints, - short initialMovement, - unsigned char backgroundColor, short &movement ); - - -#endif //!_CLASSE_BLOBRESULT_INCLUDED diff --git a/src/3rdparty/cvblobs/blob.cpp b/src/3rdparty/cvblobs/blob.cpp deleted file mode 100644 index 4b455ac2..00000000 --- a/src/3rdparty/cvblobs/blob.cpp +++ /dev/null @@ -1,706 +0,0 @@ -/************************************************************************ - Blob.cpp - -- FUNCIONALITAT: Implementaciķ de la classe CBlob -- AUTOR: Inspecta S.L. -MODIFICACIONS (Modificaciķ, Autor, Data): - - -FUNCTIONALITY: Implementation of the CBlob class and some helper classes to perform - some calculations on it -AUTHOR: Inspecta S.L. -MODIFICATIONS (Modification, Author, Date): - -**************************************************************************/ - - -#include "blob.h" - - -CBlob::CBlob() -{ - m_area = m_perimeter = -1; - m_externPerimeter = m_meanGray = m_stdDevGray = -1; - m_boundingBox.width = -1; - m_ellipse.size.width = -1; - m_storage = NULL; - m_id = -1; -} -CBlob::CBlob( t_labelType id, CvPoint startPoint, CvSize originalImageSize ) -{ - m_id = id; - m_area = m_perimeter = -1; - m_externPerimeter = m_meanGray = m_stdDevGray = -1; - m_boundingBox.width = -1; - m_ellipse.size.width = -1; - m_storage = cvCreateMemStorage(); - m_externalContour = CBlobContour(startPoint, m_storage); - m_originalImageSize = originalImageSize; -} -//! Copy constructor -CBlob::CBlob( const CBlob &src ) -{ - m_storage = NULL; - *this = src; -} - -CBlob::CBlob( const CBlob *src ) -{ - if (src != NULL ) - { - m_storage = NULL; - *this = *src; - } -} - -CBlob& CBlob::operator=(const CBlob &src ) -{ - if( this != &src ) - { - m_id = src.m_id; - m_area = src.m_area; - m_perimeter = src.m_perimeter; - m_externPerimeter = src.m_externPerimeter; - m_meanGray = src.m_meanGray; - m_stdDevGray = src.m_stdDevGray; - m_boundingBox = src.m_boundingBox; - m_ellipse = src.m_ellipse; - m_originalImageSize = src.m_originalImageSize; - - // clear all current blob contours - ClearContours(); - - if( m_storage ) - cvReleaseMemStorage( &m_storage ); - - m_storage = cvCreateMemStorage(); - - m_externalContour = CBlobContour(src.m_externalContour.GetStartPoint(), m_storage ); - if( src.m_externalContour.m_contour ) - m_externalContour.m_contour = cvCloneSeq( src.m_externalContour.m_contour, m_storage); - m_internalContours.clear(); - - // copy all internal contours - if( src.m_internalContours.size() ) - { - m_internalContours = t_contourList( src.m_internalContours.size() ); - t_contourList::const_iterator itSrc; - t_contourList::iterator it; - - itSrc = src.m_internalContours.begin(); - it = m_internalContours.begin(); - - while (itSrc != src.m_internalContours.end()) - { - *it = CBlobContour((*itSrc).GetStartPoint(), m_storage); - if( (*itSrc).m_contour ) - (*it).m_contour = cvCloneSeq( (*itSrc).m_contour, m_storage); - - it++; - itSrc++; - } - } - } - - return *this; -} - -CBlob::~CBlob() -{ - ClearContours(); - - if( m_storage ) - cvReleaseMemStorage( &m_storage ); -} - -void CBlob::ClearContours() -{ - t_contourList::iterator it; - - it = m_internalContours.begin(); - - while (it != m_internalContours.end()) - { - (*it).ResetChainCode(); - it++; - } - m_internalContours.clear(); - - m_externalContour.ResetChainCode(); - -} -void CBlob::AddInternalContour( const CBlobContour &newContour ) -{ - m_internalContours.push_back(newContour); -} - -//! Indica si el blob estā buit ( no té cap info associada ) -//! Shows if the blob has associated information -bool CBlob::IsEmpty() -{ - return GetExternalContour()->m_contour == NULL; -} - -/** -- FUNCIĶ: Area -- FUNCIONALITAT: Get blob area, ie. external contour area minus internal contours area -- PARĀMETRES: - - -- RESULTAT: - - -- RESTRICCIONS: - - -- AUTOR: rborras -- DATA DE CREACIĶ: 2008/04/30 -- MODIFICACIĶ: Data. Autor. Descripciķ. -*/ -double CBlob::Area() -{ - double area; - t_contourList::iterator itContour; - - area = m_externalContour.GetArea(); - - itContour = m_internalContours.begin(); - - while (itContour != m_internalContours.end() ) - { - area -= (*itContour).GetArea(); - itContour++; - } - return area; -} - -/** -- FUNCIĶ: Perimeter -- FUNCIONALITAT: Get blob perimeter, ie. sum of the lenght of all the contours -- PARĀMETRES: - - -- RESULTAT: - - -- RESTRICCIONS: - - -- AUTOR: rborras -- DATA DE CREACIĶ: 2008/04/30 -- MODIFICACIĶ: Data. Autor. Descripciķ. -*/ -double CBlob::Perimeter() -{ - double perimeter; - t_contourList::iterator itContour; - - perimeter = m_externalContour.GetPerimeter(); - - itContour = m_internalContours.begin(); - - while (itContour != m_internalContours.end() ) - { - perimeter += (*itContour).GetPerimeter(); - itContour++; - } - return perimeter; - -} - -/** -- FUNCIĶ: Exterior -- FUNCIONALITAT: Return true for extern blobs -- PARĀMETRES: - - xBorder: true to consider blobs touching horizontal borders as extern - - yBorder: true to consider blobs touching vertical borders as extern -- RESULTAT: - - -- RESTRICCIONS: - - -- AUTOR: rborras -- DATA DE CREACIĶ: 2008/05/06 -- MODIFICACIĶ: Data. Autor. Descripciķ. -*/ -int CBlob::Exterior(IplImage *mask, bool xBorder /* = true */, bool yBorder /* = true */) -{ - if (ExternPerimeter(mask, xBorder, yBorder ) > 0 ) - { - return 1; - } - - return 0; -} -/** -- FUNCIĶ: ExternPerimeter -- FUNCIONALITAT: Get extern perimeter (perimeter touching image borders) -- PARĀMETRES: - - maskImage: if != NULL, counts maskImage black pixels as external pixels and contour points touching - them are counted as external contour points. - - xBorder: true to consider blobs touching horizontal borders as extern - - yBorder: true to consider blobs touching vertical borders as extern -- RESULTAT: - - -- RESTRICCIONS: - - -- AUTOR: rborras -- DATA DE CREACIĶ: 2008/05/05 -- MODIFICACIĶ: Data. Autor. Descripciķ. -- NOTA: If CBlobContour::GetContourPoints aproximates contours with a method different that NONE, - this function will not give correct results -*/ -double CBlob::ExternPerimeter( IplImage *maskImage, bool xBorder /* = true */, bool yBorder /* = true */) -{ - t_PointList externContour, externalPoints; - CvSeqReader reader; - CvSeqWriter writer; - CvPoint actualPoint, previousPoint; - bool find = false; - int i,j; - int delta = 0; - - // it is calculated? - if( m_externPerimeter != -1 ) - { - return m_externPerimeter; - } - - // get contour pixels - externContour = m_externalContour.GetContourPoints(); - - m_externPerimeter = 0; - - // there are contour pixels? - if( externContour == NULL ) - { - return m_externPerimeter; - } - - cvStartReadSeq( externContour, &reader); - - // create a sequence with the external points of the blob - externalPoints = cvCreateSeq( externContour->flags, externContour->header_size, externContour->elem_size, - m_storage ); - cvStartAppendToSeq( externalPoints, &writer ); - previousPoint.x = -1; - - // which contour pixels touch border? - for( j=0; j< externContour->total; j++) - { - CV_READ_SEQ_ELEM( actualPoint, reader); - - find = false; - - // pixel is touching border? - if ( xBorder & ((actualPoint.x == 0) || (actualPoint.x == m_originalImageSize.width - 1 )) || - yBorder & ((actualPoint.y == 0) || (actualPoint.y == m_originalImageSize.height - 1 ))) - { - find = true; - } - else - { - if( maskImage != NULL ) - { - // verify if some of 8-connected neighbours is black in mask - char *pMask; - - pMask = (maskImage->imageData + actualPoint.x - 1 + (actualPoint.y - 1) * maskImage->widthStep); - - for ( i = 0; i < 3; i++, pMask++ ) - { - if(*pMask == 0 && !find ) - { - find = true; - break; - } - } - - if(!find) - { - pMask = (maskImage->imageData + actualPoint.x - 1 + (actualPoint.y ) * maskImage->widthStep); - - for ( i = 0; i < 3; i++, pMask++ ) - { - if(*pMask == 0 && !find ) - { - find = true; - break; - } - } - } - - if(!find) - { - pMask = (maskImage->imageData + actualPoint.x - 1 + (actualPoint.y + 1) * maskImage->widthStep); - - for ( i = 0; i < 3; i++, pMask++ ) - { - if(*pMask == 0 && !find ) - { - find = true; - break; - } - } - } - } - } - - if( find ) - { - if( previousPoint.x > 0 ) - delta = abs(previousPoint.x - actualPoint.x) + abs(previousPoint.y - actualPoint.y); - - // calculate separately each external contour segment - if( delta > 2 ) - { - cvEndWriteSeq( &writer ); - m_externPerimeter += cvArcLength( externalPoints, CV_WHOLE_SEQ, 0 ); - - cvClearSeq( externalPoints ); - cvStartAppendToSeq( externalPoints, &writer ); - delta = 0; - previousPoint.x = -1; - } - - CV_WRITE_SEQ_ELEM( actualPoint, writer ); - previousPoint = actualPoint; - } - - } - - cvEndWriteSeq( &writer ); - - m_externPerimeter += cvArcLength( externalPoints, CV_WHOLE_SEQ, 0 ); - - cvClearSeq( externalPoints ); - - // divide by two because external points have one side inside the blob and the other outside - // Perimeter of external points counts both sides, so it must be divided - m_externPerimeter /= 2.0; - - return m_externPerimeter; -} - -//! Compute blob's moment (p,q up to MAX_CALCULATED_MOMENTS) -double CBlob::Moment(int p, int q) -{ - double moment; - t_contourList::iterator itContour; - - moment = m_externalContour.GetMoment(p,q); - - itContour = m_internalContours.begin(); - - while (itContour != m_internalContours.end() ) - { - moment -= (*itContour).GetMoment(p,q); - itContour++; - } - return moment; -} - -/** -- FUNCIĶ: Mean -- FUNCIONALITAT: Get blob mean color in input image -- PARĀMETRES: - - image: image from gray color are extracted -- RESULTAT: - - -- RESTRICCIONS: - - -- AUTOR: rborras -- DATA DE CREACIĶ: 2008/05/06 -- MODIFICACIĶ: Data. Autor. Descripciķ. -*/ -double CBlob::Mean( IplImage *image ) -{ - // it is calculated? -/* if( m_meanGray != -1 ) - { - return m_meanGray; - } -*/ - // Create a mask with same size as blob bounding box - IplImage *mask; - CvScalar mean, std; - CvPoint offset; - - GetBoundingBox(); - - if (m_boundingBox.height == 0 ||m_boundingBox.width == 0 || !CV_IS_IMAGE( image )) - { - m_meanGray = 0; - return m_meanGray; - } - - // apply ROI and mask to input image to compute mean gray and standard deviation - mask = cvCreateImage( cvSize(m_boundingBox.width, m_boundingBox.height), IPL_DEPTH_8U, 1); - cvSetZero(mask); - - offset.x = -m_boundingBox.x; - offset.y = -m_boundingBox.y; - - // draw contours on mask - cvDrawContours( mask, m_externalContour.GetContourPoints(), CV_RGB(255,255,255), CV_RGB(255,255,255),0, CV_FILLED, 8, - offset ); - - // draw internal contours - t_contourList::iterator it = m_internalContours.begin(); - while(it != m_internalContours.end() ) - { - cvDrawContours( mask, (*it).GetContourPoints(), CV_RGB(0,0,0), CV_RGB(0,0,0),0, CV_FILLED, 8, - offset ); - it++; - } - - cvSetImageROI( image, m_boundingBox ); - cvAvgSdv( image, &mean, &std, mask ); - - m_meanGray = mean.val[0]; - m_stdDevGray = std.val[0]; - - cvReleaseImage( &mask ); - cvResetImageROI( image ); - - return m_meanGray; -} - -double CBlob::StdDev( IplImage *image ) -{ - // it is calculated? -/* if( m_stdDevGray != -1 ) - { - return m_stdDevGray; - } -*/ - // call mean calculation (where also standard deviation is calculated) - Mean( image ); - - return m_stdDevGray; -} -/** -- FUNCIĶ: GetBoundingBox -- FUNCIONALITAT: Get bounding box (without rotation) of a blob -- PARĀMETRES: - - -- RESULTAT: - - -- RESTRICCIONS: - - -- AUTOR: rborras -- DATA DE CREACIĶ: 2008/05/06 -- MODIFICACIĶ: Data. Autor. Descripciķ. -*/ -CvRect CBlob::GetBoundingBox() -{ - // it is calculated? - if( m_boundingBox.width != -1 ) - { - return m_boundingBox; - } - - t_PointList externContour; - CvSeqReader reader; - CvPoint actualPoint; - - // get contour pixels - externContour = m_externalContour.GetContourPoints(); - - // it is an empty blob? - if( !externContour ) - { - m_boundingBox.x = 0; - m_boundingBox.y = 0; - m_boundingBox.width = 0; - m_boundingBox.height = 0; - - return m_boundingBox; - } - - cvStartReadSeq( externContour, &reader); - - m_boundingBox.x = m_originalImageSize.width; - m_boundingBox.y = m_originalImageSize.height; - m_boundingBox.width = 0; - m_boundingBox.height = 0; - - for( int i=0; i< externContour->total; i++) - { - CV_READ_SEQ_ELEM( actualPoint, reader); - - m_boundingBox.x = MIN( actualPoint.x, m_boundingBox.x ); - m_boundingBox.y = MIN( actualPoint.y, m_boundingBox.y ); - - m_boundingBox.width = MAX( actualPoint.x, m_boundingBox.width ); - m_boundingBox.height = MAX( actualPoint.y, m_boundingBox.height ); - } - - //m_boundingBox.x = max( m_boundingBox.x , 0 ); - //m_boundingBox.y = max( m_boundingBox.y , 0 ); - - m_boundingBox.width -= m_boundingBox.x; - m_boundingBox.height -= m_boundingBox.y; - - return m_boundingBox; -} - -/** -- FUNCIĶ: GetEllipse -- FUNCIONALITAT: Calculates bounding ellipse of external contour points -- PARĀMETRES: - - -- RESULTAT: - - -- RESTRICCIONS: - - -- AUTOR: rborras -- DATA DE CREACIĶ: 2008/05/06 -- MODIFICACIĶ: Data. Autor. Descripciķ. -- NOTA: Calculation is made using second order moment aproximation -*/ -CvBox2D CBlob::GetEllipse() -{ - // it is calculated? - if( m_ellipse.size.width != -1 ) - return m_ellipse; - - double u00,u11,u01,u10,u20,u02, delta, num, den, temp; - - // central moments calculation - u00 = Moment(0,0); - - // empty blob? - if ( u00 <= 0 ) - { - m_ellipse.size.width = 0; - m_ellipse.size.height = 0; - m_ellipse.center.x = 0; - m_ellipse.center.y = 0; - m_ellipse.angle = 0; - return m_ellipse; - } - u10 = Moment(1,0) / u00; - u01 = Moment(0,1) / u00; - - u11 = -(Moment(1,1) - Moment(1,0) * Moment(0,1) / u00 ) / u00; - u20 = (Moment(2,0) - Moment(1,0) * Moment(1,0) / u00 ) / u00; - u02 = (Moment(0,2) - Moment(0,1) * Moment(0,1) / u00 ) / u00; - - - // elipse calculation - delta = sqrt( 4*u11*u11 + (u20-u02)*(u20-u02) ); - m_ellipse.center.x = u10; - m_ellipse.center.y = u01; - - temp = u20 + u02 + delta; - if( temp > 0 ) - { - m_ellipse.size.width = sqrt( 2*(u20 + u02 + delta )); - } - else - { - m_ellipse.size.width = 0; - return m_ellipse; - } - - temp = u20 + u02 - delta; - if( temp > 0 ) - { - m_ellipse.size.height = sqrt( 2*(u20 + u02 - delta ) ); - } - else - { - m_ellipse.size.height = 0; - return m_ellipse; - } - - // elipse orientation - if (u20 > u02) - { - num = u02 - u20 + sqrt((u02 - u20)*(u02 - u20) + 4*u11*u11); - den = 2*u11; - } - else - { - num = 2*u11; - den = u20 - u02 + sqrt((u20 - u02)*(u20 - u02) + 4*u11*u11); - } - if( num != 0 && den != 00 ) - { - m_ellipse.angle = 180.0 + (180.0 / CV_PI) * atan( num / den ); - } - else - { - m_ellipse.angle = 0; - } - - return m_ellipse; - -} - -/** -- FUNCTION: FillBlob -- FUNCTIONALITY: - - Fills the blob with a specified colour -- PARAMETERS: - - imatge: where to paint - - color: colour to paint the blob -- RESULT: - - modifies input image and returns the seed point used to fill the blob -- RESTRICTIONS: -- AUTHOR: Ricard Borrās -- CREATION DATE: 25-05-2005. -- MODIFICATION: Date. Author. Description. -*/ -void CBlob::FillBlob( IplImage *imatge, CvScalar color, int offsetX /*=0*/, int offsetY /*=0*/) -{ - cvDrawContours( imatge, m_externalContour.GetContourPoints(), color, color,0, CV_FILLED, 8 ); -} - - -/** -- FUNCTION: GetConvexHull -- FUNCTIONALITY: Calculates the convex hull polygon of the blob -- PARAMETERS: - - dst: where to store the result -- RESULT: - - true if no error ocurred -- RESTRICTIONS: -- AUTHOR: Ricard Borrās -- CREATION DATE: 25-05-2005. -- MODIFICATION: Date. Author. Description. -*/ -t_PointList CBlob::GetConvexHull() -{ - CvSeq *convexHull = NULL; - - if( m_externalContour.GetContourPoints() ) - convexHull = cvConvexHull2( m_externalContour.GetContourPoints(), m_storage, - CV_COUNTER_CLOCKWISE, 1 ); - - return convexHull; -} - -/** -- FUNCTION: JoinBlob -- FUNCTIONALITY: Add's external contour to current external contour -- PARAMETERS: - - blob: blob from which extract the added external contour -- RESULT: - - true if no error ocurred -- RESTRICTIONS: Only external contours are added -- AUTHOR: Ricard Borrās -- CREATION DATE: 25-05-2005. -- MODIFICATION: Date. Author. Description. -*/ -void CBlob::JoinBlob( CBlob *blob ) -{ - CvSeqWriter writer; - CvSeqReader reader; - t_chainCode chainCode; - - cvStartAppendToSeq( m_externalContour.GetChainCode(), &writer ); - cvStartReadSeq( blob->GetExternalContour()->GetChainCode(), &reader ); - - for (int i = 0; i < blob->GetExternalContour()->GetChainCode()->total; i++ ) - { - CV_READ_SEQ_ELEM( chainCode, reader ); - CV_WRITE_SEQ_ELEM( chainCode, writer ); - } - cvEndWriteSeq( &writer ); - -} diff --git a/src/3rdparty/cvblobs/blob.h b/src/3rdparty/cvblobs/blob.h deleted file mode 100644 index 89729d40..00000000 --- a/src/3rdparty/cvblobs/blob.h +++ /dev/null @@ -1,172 +0,0 @@ -/************************************************************************ - Blob.h - -FUNCIONALITAT: Definiciķ de la classe CBlob -AUTOR: Inspecta S.L. -MODIFICACIONS (Modificaciķ, Autor, Data): - -FUNCTIONALITY: Definition of the CBlob class and some helper classes to perform - some calculations on it -AUTHOR: Inspecta S.L. -MODIFICATIONS (Modification, Author, Date): - -**************************************************************************/ - -//! Disable warnings referred to 255 character truncation for the std:map -#pragma warning( disable : 4786 ) - -#ifndef CBLOB_INSPECTA_INCLUDED -#define CBLOB_INSPECTA_INCLUDED - -#include -#include "BlobLibraryConfiguration.h" -#include "BlobContour.h" - - -#ifdef BLOB_OBJECT_FACTORY - //! Object factory pattern implementation - #include "..\inspecta\DesignPatterns\ObjectFactory.h" -#endif - - -//! Type of labelled images -typedef unsigned int t_labelType; - - -//! Blob class -class CBlob -{ - typedef std::list t_contourList; - -public: - CBlob(); - CBlob( t_labelType id, CvPoint startPoint, CvSize originalImageSize ); - ~CBlob(); - - //! Copy constructor - CBlob( const CBlob &src ); - CBlob( const CBlob *src ); - - //! Operador d'assignaciķ - //! Assigment operator - CBlob& operator=(const CBlob &src ); - - //! Adds a new internal contour to the blob - void AddInternalContour( const CBlobContour &newContour ); - - //! Retrieves contour in Freeman's chain code - CBlobContour *GetExternalContour() - { - return &m_externalContour; - } - - //! Retrieves blob storage - CvMemStorage *GetStorage() - { - return m_storage; - } - - //! Get label ID - t_labelType GetID() - { - return m_id; - } - //! > 0 for extern blobs, 0 if not - int Exterior( IplImage *mask, bool xBorder = true, bool yBorder = true ); - //! Compute blob's area - double Area(); - //! Compute blob's perimeter - double Perimeter(); - //! Compute blob's moment (p,q up to MAX_CALCULATED_MOMENTS) - double Moment(int p, int q); - - //! Compute extern perimeter - double ExternPerimeter( IplImage *mask, bool xBorder = true, bool yBorder = true ); - - //! Get mean grey color - double Mean( IplImage *image ); - - //! Get standard deviation grey color - double StdDev( IplImage *image ); - - //! Indica si el blob estā buit ( no té cap info associada ) - //! Shows if the blob has associated information - bool IsEmpty(); - - //! Retorna el poligon convex del blob - //! Calculates the convex hull of the blob - t_PointList GetConvexHull(); - - //! Pinta l'interior d'un blob d'un color determinat - //! Paints the blob in an image - void FillBlob( IplImage *imatge, CvScalar color, int offsetX = 0, int offsetY = 0 ); - - //! Join a blob to current one (add's contour - void JoinBlob( CBlob *blob ); - - //! Get bounding box - CvRect GetBoundingBox(); - //! Get bounding ellipse - CvBox2D GetEllipse(); - - //! Minimun X - double MinX() - { - return GetBoundingBox().x; - } - //! Minimun Y - double MinY() - { - return GetBoundingBox().y; - } - //! Maximun X - double MaxX() - { - return GetBoundingBox().x + GetBoundingBox().width; - } - //! Maximun Y - double MaxY() - { - return GetBoundingBox().y + GetBoundingBox().height; - } -private: - - //! Deallocates all contours - void ClearContours(); - ////////////////////////////////////////////////////////////////////////// - // Blob contours - ////////////////////////////////////////////////////////////////////////// - - - //! Contour storage memory - CvMemStorage *m_storage; - //! External contour of the blob (crack codes) - CBlobContour m_externalContour; - //! Internal contours (crack codes) - t_contourList m_internalContours; - - ////////////////////////////////////////////////////////////////////////// - // Blob features - ////////////////////////////////////////////////////////////////////////// - - //! Label number - t_labelType m_id; - //! Area - double m_area; - //! Perimeter - double m_perimeter; - //! Extern perimeter from blob - double m_externPerimeter; - //! Mean gray color - double m_meanGray; - //! Standard deviation from gray color blob distribution - double m_stdDevGray; - //! Bounding box - CvRect m_boundingBox; - //! Bounding ellipse - CvBox2D m_ellipse; - //! Sizes from image where blob is extracted - CvSize m_originalImageSize; -}; - -#endif //CBLOB_INSPECTA_INCLUDED diff --git a/src/libopentld/CMakeLists.txt b/src/libopentld/CMakeLists.txt index 740c07d2..9a4faafc 100644 --- a/src/libopentld/CMakeLists.txt +++ b/src/libopentld/CMakeLists.txt @@ -2,7 +2,6 @@ include_directories(imacq mftracker tld - ../3rdparty/cvblobs ${OpenCV_INCLUDE_DIRS}) link_directories(${OpenCV_LIB_DIR}) diff --git a/src/libopentld/tld/DetectorCascade.cpp b/src/libopentld/tld/DetectorCascade.cpp index 16d7dbe1..b044340e 100644 --- a/src/libopentld/tld/DetectorCascade.cpp +++ b/src/libopentld/tld/DetectorCascade.cpp @@ -111,7 +111,7 @@ void DetectorCascade::propagateMembers() clustering->windows = windows; clustering->numWindows = numWindows; - foregroundDetector->minBlobSize = minSize * minSize; + foregroundDetector->minArea = (double)(minSize * minSize); foregroundDetector->detectionResult = detectionResult; varianceFilter->detectionResult = detectionResult; diff --git a/src/libopentld/tld/ForegroundDetector.cpp b/src/libopentld/tld/ForegroundDetector.cpp index bcf8a214..5159be5d 100644 --- a/src/libopentld/tld/ForegroundDetector.cpp +++ b/src/libopentld/tld/ForegroundDetector.cpp @@ -25,8 +25,6 @@ #include "ForegroundDetector.h" -#include "BlobResult.h" - using namespace cv; namespace tld @@ -35,7 +33,7 @@ namespace tld ForegroundDetector::ForegroundDetector() { fgThreshold = 16; - minBlobSize = 0; + minArea = 0; } ForegroundDetector::~ForegroundDetector() @@ -55,22 +53,27 @@ void ForegroundDetector::nextIteration(const Mat &img) Mat absImg = Mat(img.cols, img.rows, img.type()); Mat threshImg = Mat(img.cols, img.rows, img.type()); + std::vector > contours; + std::vector > selected_contours; + std::vector hierarchy; absdiff(bgImg, img, absImg); threshold(absImg, threshImg, fgThreshold, 255, CV_THRESH_BINARY); - IplImage im = (IplImage)threshImg; - CBlobResult blobs = CBlobResult(&im, NULL, 0); + findContours(absImg, contours, hierarchy, + CV_RETR_TREE, CV_CHAIN_APPROX_SIMPLE, Point(0, 0)); - blobs.Filter(blobs, B_EXCLUDE, CBlobGetArea(), B_LESS, minBlobSize); + for(size_t i = 0; i < contours.size(); i++) + if(contourArea(contours[i]) > minArea) + selected_contours.push_back(contours[i]); std::vector* fgList = detectionResult->fgList; fgList->clear(); - for(int i = 0; i < blobs.GetNumBlobs(); i++) + for(size_t i = 0; i < selected_contours.size(); i++) { - CBlob *blob = blobs.GetBlob(i); - CvRect rect = blob->GetBoundingBox(); + std::vector contour = selected_contours[i]; + Rect rect = boundingRect(contour); fgList->push_back(rect); } diff --git a/src/libopentld/tld/ForegroundDetector.h b/src/libopentld/tld/ForegroundDetector.h index 0fff58c0..56004439 100644 --- a/src/libopentld/tld/ForegroundDetector.h +++ b/src/libopentld/tld/ForegroundDetector.h @@ -40,7 +40,7 @@ class ForegroundDetector { public: int fgThreshold; - int minBlobSize; + double minArea; cv::Mat bgImg; DetectionResult *detectionResult; diff --git a/src/opentld/CMakeLists.txt b/src/opentld/CMakeLists.txt index 23170b33..31061086 100644 --- a/src/opentld/CMakeLists.txt +++ b/src/opentld/CMakeLists.txt @@ -5,7 +5,6 @@ include_directories(main ../libopentld/imacq ../libopentld/mftracker ../libopentld/tld - ../3rdparty/cvblobs ${OpenCV_INCLUDE_DIRS}) if(NOT USE_SYSTEM_LIBS) @@ -26,14 +25,14 @@ add_library(main main/Settings.h main/Trajectory.h) -target_link_libraries(main libopentld cvblobs config++ ${OpenCV_LIBS}) +target_link_libraries(main libopentld config++ ${OpenCV_LIBS}) #------------------------------------------------------------------------------- # opentld add_executable(opentld OpenTLD.cpp) -target_link_libraries(opentld main libopentld cvblobs config++ ${OpenCV_LIBS}) +target_link_libraries(opentld main libopentld config++ ${OpenCV_LIBS}) install(TARGETS opentld DESTINATION bin) @@ -57,7 +56,7 @@ if(BUILD_QOPENTLD) set(QOPENTLD_SOURCES ${QOPENTLD_SOURCES} ${QOPENTLD_RCS_CPP} ${QOPENTLD_HEADERS_MOC} ${QOPENTLD_FORMS_HEADERS}) add_executable(qopentld ${QOPENTLD_SOURCES}) - target_link_libraries(qopentld main libopentld cvblobs config++ ${OpenCV_LIBS} ${QT_LIBRARIES}) + target_link_libraries(qopentld main libopentld config++ ${OpenCV_LIBS} ${QT_LIBRARIES}) install(TARGETS qopentld DESTINATION bin) endif(BUILD_QOPENTLD)