root / vision / cvblobs8.3 / BlobContour.h @ master
History | View | Annotate | Download (1.94 KB)
1 | b11b2b30 | Tom Mullins | #ifndef BLOBCONTOUR_H_INCLUDED
|
---|---|---|---|
2 | #define BLOBCONTOUR_H_INCLUDED
|
||
3 | |||
4 | |||
5 | #include "list" |
||
6 | #include <opencv/cv.h> |
||
7 | //#include "cxtypes.h" //AO
|
||
8 | #include <opencv/cxcore.h> // |
||
9 | |||
10 | //! Type of chain codes
|
||
11 | typedef unsigned char t_chainCode; |
||
12 | //! Type of list of chain codes
|
||
13 | typedef CvSeq* t_chainCodeList;
|
||
14 | //! Type of list of points
|
||
15 | typedef CvSeq* t_PointList;
|
||
16 | |||
17 | |||
18 | //! Max order of calculated moments
|
||
19 | #define MAX_MOMENTS_ORDER 3 |
||
20 | |||
21 | |||
22 | //! Blob contour class (in crack code)
|
||
23 | class CBlobContour |
||
24 | { |
||
25 | friend class CBlob; |
||
26 | friend class CBlobProperties; //AO
|
||
27 | |||
28 | public:
|
||
29 | //! Constructors
|
||
30 | CBlobContour(); |
||
31 | CBlobContour(CvPoint startPoint, CvMemStorage *storage ); |
||
32 | //! Copy constructor
|
||
33 | CBlobContour( CBlobContour *source ); |
||
34 | |||
35 | ~CBlobContour(); |
||
36 | //! Assigment operator
|
||
37 | CBlobContour& operator=( const CBlobContour &source );
|
||
38 | |||
39 | //! Add chain code to contour
|
||
40 | void AddChainCode(t_chainCode code);
|
||
41 | |||
42 | //! Return freeman chain coded contour
|
||
43 | t_chainCodeList GetChainCode() |
||
44 | { |
||
45 | return m_contour;
|
||
46 | } |
||
47 | |||
48 | bool IsEmpty()
|
||
49 | { |
||
50 | return m_contour == NULL || m_contour->total == 0; |
||
51 | } |
||
52 | |||
53 | //! Return all contour points
|
||
54 | t_chainCodeList GetContourPoints(); |
||
55 | |||
56 | protected:
|
||
57 | |||
58 | CvPoint GetStartPoint() const
|
||
59 | { |
||
60 | return m_startPoint;
|
||
61 | } |
||
62 | |||
63 | //! Clears chain code contour
|
||
64 | void ResetChainCode();
|
||
65 | |||
66 | |||
67 | |||
68 | //! Computes area from contour
|
||
69 | double GetArea();
|
||
70 | //! Computes perimeter from contour
|
||
71 | double GetPerimeter();
|
||
72 | //! Get contour moment (p,q up to MAX_CALCULATED_MOMENTS)
|
||
73 | double GetMoment(int p, int q); |
||
74 | |||
75 | //! Crack code list
|
||
76 | t_chainCodeList m_contour; |
||
77 | |||
78 | private:
|
||
79 | //! Starting point of the contour
|
||
80 | CvPoint m_startPoint; |
||
81 | //! All points from the contour
|
||
82 | t_PointList m_contourPoints; |
||
83 | |||
84 | |||
85 | |||
86 | //! Computed area from contour
|
||
87 | double m_area;
|
||
88 | //! Computed perimeter from contour
|
||
89 | double m_perimeter;
|
||
90 | //! Computed moments from contour
|
||
91 | CvMoments m_moments; |
||
92 | |||
93 | //! Pointer to storage
|
||
94 | CvMemStorage *m_parentStorage; |
||
95 | }; |
||
96 | |||
97 | #endif //!BLOBCONTOUR_H_INCLUDED |
||
98 | |||
99 |