root / vision / cvblobs8.3 / testBlobs / BlobResult.h @ b11b2b30
History | View | Annotate | Download (5.33 KB)
1 | 8711dd52 | Nick Stanley | /************************************************************************
|
---|---|---|---|
2 | BlobResult.h
|
||
3 |
|
||
4 | FUNCIONALITAT: Definici? de la classe CBlobResult
|
||
5 | AUTOR: Inspecta S.L.
|
||
6 | MODIFICACIONS (Modificaci?, Autor, Data):
|
||
7 | |||
8 | FUNCTIONALITY: Definition of the CBlobResult class
|
||
9 | AUTHOR: Inspecta S.L.
|
||
10 | MODIFICATIONS (Modification, Author, Date):
|
||
11 | |||
12 | **************************************************************************/
|
||
13 | |||
14 | |||
15 | #if !defined(_CLASSE_BLOBRESULT_INCLUDED)
|
||
16 | #define _CLASSE_BLOBRESULT_INCLUDED
|
||
17 | |||
18 | #if _MSC_VER > 1000 |
||
19 | #pragma once
|
||
20 | #endif // _MSC_VER > 1000 |
||
21 | |||
22 | #include "BlobLibraryConfiguration.h" |
||
23 | #include <math.h> |
||
24 | #include <opencv/cxcore.h> |
||
25 | |||
26 | #ifdef MATRIXCV_ACTIU
|
||
27 | #include "matrixCV.h" |
||
28 | #else
|
||
29 | // llibreria STL
|
||
30 | #include "vector" |
||
31 | //! Vector de doubles
|
||
32 | typedef std::vector<double> double_stl_vector; |
||
33 | #endif
|
||
34 | |||
35 | #include <vector> // vectors de la STL |
||
36 | #include <functional> |
||
37 | #include "blob.h" |
||
38 | #include "BlobOperators.h" |
||
39 | #include "ComponentLabeling.h" |
||
40 | /**************************************************************************
|
||
41 | Filtres / Filters
|
||
42 | **************************************************************************/
|
||
43 | |||
44 | //! accions que es poden fer amb els filtres
|
||
45 | //! Actions performed by a filter (include or exclude blobs)
|
||
46 | #define B_INCLUDE 1L |
||
47 | #define B_EXCLUDE 2L |
||
48 | |||
49 | //! condicions sobre els filtres
|
||
50 | //! Conditions to apply the filters
|
||
51 | #define B_EQUAL 3L |
||
52 | #define B_NOT_EQUAL 4L |
||
53 | #define B_GREATER 5L |
||
54 | #define B_LESS 6L |
||
55 | #define B_GREATER_OR_EQUAL 7L |
||
56 | #define B_LESS_OR_EQUAL 8L |
||
57 | #define B_INSIDE 9L |
||
58 | #define B_OUTSIDE 10L |
||
59 | |||
60 | |||
61 | /**************************************************************************
|
||
62 | Excepcions / Exceptions
|
||
63 | **************************************************************************/
|
||
64 | |||
65 | //! Excepcions llen?ades per les funcions:
|
||
66 | #define EXCEPTION_BLOB_OUT_OF_BOUNDS 1000 |
||
67 | #define EXCEPCIO_CALCUL_BLOBS 1001 |
||
68 | |||
69 | /**
|
||
70 | Classe que cont? un conjunt de blobs i permet extreure'n propietats
|
||
71 | o filtrar-los segons determinats criteris.
|
||
72 | Class to calculate the blobs of an image and calculate some properties
|
||
73 | on them. Also, the class provides functions to filter the blobs using
|
||
74 | some criteria.
|
||
75 | */
|
||
76 | class CBlobResult |
||
77 | { |
||
78 | public:
|
||
79 | |||
80 | //! constructor estandard, crea un conjunt buit de blobs
|
||
81 | //! Standard constructor, it creates an empty set of blobs
|
||
82 | CBlobResult(); |
||
83 | //! constructor a partir d'una imatge
|
||
84 | //! Image constructor, it creates an object with the blobs of the image
|
||
85 | CBlobResult(IplImage *source, IplImage *mask, uchar backgroundColor); |
||
86 | //! constructor de c?pia
|
||
87 | //! Copy constructor
|
||
88 | CBlobResult( const CBlobResult &source );
|
||
89 | //! Destructor
|
||
90 | virtual ~CBlobResult(); |
||
91 | |||
92 | //! operador = per a fer assignacions entre CBlobResult
|
||
93 | //! Assigment operator
|
||
94 | CBlobResult& operator=(const CBlobResult& source);
|
||
95 | //! operador + per concatenar dos CBlobResult
|
||
96 | //! Addition operator to concatenate two sets of blobs
|
||
97 | CBlobResult operator+( const CBlobResult& source ) const; |
||
98 | |||
99 | //! Afegeix un blob al conjunt
|
||
100 | //! Adds a blob to the set of blobs
|
||
101 | void AddBlob( CBlob *blob );
|
||
102 | |||
103 | #ifdef MATRIXCV_ACTIU
|
||
104 | //! Calcula un valor sobre tots els blobs de la classe retornant una MatrixCV
|
||
105 | //! Computes some property on all the blobs of the class
|
||
106 | double_vector GetResult( funcio_calculBlob *evaluador ) const;
|
||
107 | #endif
|
||
108 | //! Calcula un valor sobre tots els blobs de la classe retornant un std::vector<double>
|
||
109 | //! Computes some property on all the blobs of the class
|
||
110 | double_stl_vector GetSTLResult( funcio_calculBlob *evaluador ) const;
|
||
111 | |||
112 | //! Calcula un valor sobre un blob de la classe
|
||
113 | //! Computes some property on one blob of the class
|
||
114 | double GetNumber( int indexblob, funcio_calculBlob *evaluador ) const; |
||
115 | |||
116 | //! Retorna aquells blobs que compleixen les condicions del filtre en el destination
|
||
117 | //! Filters the blobs of the class using some property
|
||
118 | void Filter(CBlobResult &dst,
|
||
119 | int filterAction, funcio_calculBlob *evaluador,
|
||
120 | int condition, double lowLimit, double highLimit = 0 ); |
||
121 | void Filter(CBlobResult &dst,
|
||
122 | int filterAction, funcio_calculBlob *evaluador,
|
||
123 | int condition, double lowLimit, double highLimit = 0 ) const; |
||
124 | |||
125 | //! Retorna l'en?ssim blob segons un determinat criteri
|
||
126 | //! Sorts the blobs of the class acording to some criteria and returns the n-th blob
|
||
127 | void GetNthBlob( funcio_calculBlob *criteri, int nBlob, CBlob &dst ) const; |
||
128 | |||
129 | //! Retorna el blob en?ssim
|
||
130 | //! Gets the n-th blob of the class ( without sorting )
|
||
131 | CBlob GetBlob(int indexblob) const; |
||
132 | CBlob *GetBlob(int indexblob);
|
||
133 | |||
134 | //! Elimina tots els blobs de l'objecte
|
||
135 | //! Clears all the blobs of the class
|
||
136 | void ClearBlobs();
|
||
137 | |||
138 | //! Escriu els blobs a un fitxer
|
||
139 | //! Prints some features of all the blobs in a file
|
||
140 | void PrintBlobs( char *nom_fitxer ) const; |
||
141 | |||
142 | |||
143 | //Metodes GET/SET
|
||
144 | |||
145 | //! Retorna el total de blobs
|
||
146 | //! Gets the total number of blobs
|
||
147 | int GetNumBlobs() const |
||
148 | { |
||
149 | return(m_blobs.size());
|
||
150 | } |
||
151 | |||
152 | |||
153 | private:
|
||
154 | |||
155 | //! Funci? per gestionar els errors
|
||
156 | //! Function to manage the errors
|
||
157 | void RaiseError(const int errorCode) const; |
||
158 | |||
159 | //! Does the Filter method job
|
||
160 | void DoFilter(CBlobResult &dst,
|
||
161 | int filterAction, funcio_calculBlob *evaluador,
|
||
162 | int condition, double lowLimit, double highLimit = 0) const; |
||
163 | |||
164 | protected:
|
||
165 | |||
166 | //! Vector amb els blobs
|
||
167 | //! Vector with all the blobs
|
||
168 | Blob_vector m_blobs; |
||
169 | }; |
||
170 | |||
171 | #endif // !defined(_CLASSE_BLOBRESULT_INCLUDED) |