/************************************************************************ BlobGroup.h FUNCTIONALITY: Definition of the BlobGroup 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 "ComponentLabeling.h" #include "defines.h" #include #include "opencv2/core/core_c.h" #include #include #include #include #include #include #include #include #include #include "blob.h" #include "BlobOperators.h" #include "ComponentLabeling.h" class BlobGroup { public: //! Constructor, opencv 1.0 and 2.0 interfaces. BlobGroup(); BlobGroup(const BlobGroup& source); //! Destructor virtual ~BlobGroup(); //! Assigment operator BlobGroup& operator=(const BlobGroup& source); //! Addition operator to concatenate two sets of blobs BlobGroup operator+(const BlobGroup& source) const; //! Adds a blob to the set of blobs void addBlob(Blob* blob); #ifdef MATRIXCV_ACTIU //! Computes some property on all the blobs of the class DoubleVector getResult(BlobOperator* evaluator) const; #endif //! Computes some property on all the blobs of the class DoubleStlVector getStlResult(BlobOperator* evaluator) const; //! Computes some property on one blob of the class double getNumber(int indexblob, BlobOperator* evaluator) const; //! Filters the blobs of the class using some property void filter(BlobGroup& dst, int filterAction, BlobOperator* evaluator, int condition, double lowLimit, double highLimit = 0); void filter(BlobGroup& dst, int filterAction, BlobOperator* evaluator, int condition, double lowLimit, double highLimit = 0) const; void filter(BlobGroup& dst, FilterAction filterAction, BlobOperator* evaluator, FilterCondition condition, double lowLimit, double highLimit = 0); //! Sorts the blobs of the class acording to some criteria and returns the n-th blob void getNthBlob(BlobOperator* criteria, int nBlob, Blob& dst) const; //! Gets the n-th blob of the class (without sorting) Blob getBlob(int index) const; Blob* getBlob(int index); Blob getBlobByID(LabelID id) const; Blob* getBlobByID(LabelID id); //! Clears all the blobs of the class void clearBlobs(); //! Prints some features of all the blobs in a file void printBlobs(char* fileName) const; //! Returns blob with center nearest to point pt Blob* getBlobNearestTo(const cv::Point& pt); //! Gets the total number of blobs int getNumBlobs() const { return (m_blobs.size()); } const BlobVector& getBlobVector() { return m_blobs; } private: //! Function to manage the errors void raiseError(int errorCode) const; //! Does the filter method job void doFilter(BlobGroup& dst, int filterAction, BlobOperator* evaluator, int condition, double lowLimit, double highLimit = 0) const; protected: //! Vector with all the blobs BlobVector m_blobs; friend class BlobDetector; }; #endif // !defined(_CLASSE_BLOBRESULT_INCLUDED)