You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

97 lines
1.9 KiB

7 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. #ifndef BLOBCONTOUR_H_INCLUDED
  2. #define BLOBCONTOUR_H_INCLUDED
  3. #include <list>
  4. #include <opencv/cv.h>
  5. #include <opencv/cxcore.h>
  6. //! Type of chain codes
  7. typedef unsigned char t_chainCode;
  8. //! Type of list of chain codes
  9. typedef CvSeq* t_chainCodeList;
  10. //! Type of list of points
  11. typedef CvSeq* t_PointList;
  12. //! Max order of calculated moments
  13. #define MAX_MOMENTS_ORDER 3
  14. //! Blob contour class (in crack code)
  15. class CBlobContour
  16. {
  17. friend class CBlob;
  18. public:
  19. //! Constructors
  20. CBlobContour();
  21. CBlobContour(CvPoint startPoint, CvMemStorage *storage );
  22. //! Copy constructor
  23. CBlobContour( CBlobContour *source );
  24. ~CBlobContour();
  25. //! Assigment operator
  26. CBlobContour& operator=( const CBlobContour &source );
  27. //! Add chain code to contour
  28. void AddChainCode(t_chainCode code);
  29. //! Return freeman chain coded contour
  30. t_chainCodeList GetChainCode()
  31. {
  32. return m_contour;
  33. }
  34. bool IsEmpty()
  35. {
  36. return m_contour == NULL || m_contour->total == 0;
  37. }
  38. //! Return all contour points
  39. t_chainCodeList GetContourPoints();
  40. protected:
  41. CvPoint GetStartPoint() const
  42. {
  43. return m_startPoint;
  44. }
  45. //! Clears chain code contour
  46. void ResetChainCode();
  47. public:
  48. //! Computes area from contour
  49. float GetArea();
  50. //! Computes perimeter from contour
  51. float GetPerimeter();
  52. //! Get contour moment (p,q up to MAX_CALCULATED_MOMENTS)
  53. float GetMoment(int p, int q);
  54. //! Crack code list
  55. t_chainCodeList m_contour;
  56. private:
  57. //! Starting point of the contour
  58. CvPoint m_startPoint;
  59. //! All points from the contour
  60. t_PointList m_contourPoints;
  61. //! Computed area from contour
  62. float m_area;
  63. //! Computed perimeter from contour
  64. float m_perimeter;
  65. //! Computed moments from contour
  66. CvMoments m_moments;
  67. //! Pointer to storage
  68. CvMemStorage *m_parentStorage;
  69. };
  70. #endif //!BLOBCONTOUR_H_INCLUDED