Commit ff142618affba0492249cb2655b54d88ab11e740

Authored by Scott Klum
1 parent db4fcc54

Added approximation to fillcontours

openbr/plugins/imgproc/fillcontours.cpp
@@ -32,8 +32,19 @@ class FillContoursTransform : public UntrainableTransform @@ -32,8 +32,19 @@ class FillContoursTransform : public UntrainableTransform
32 { 32 {
33 Q_OBJECT 33 Q_OBJECT
34 34
  35 + Q_ENUMS(Approximation)
  36 + Q_PROPERTY(Approximation approximation READ get_approximation WRITE set_approximation RESET reset_approximation STORED false)
35 Q_PROPERTY(float epsilon READ get_epsilon WRITE set_epsilon RESET reset_epsilon STORED false) 37 Q_PROPERTY(float epsilon READ get_epsilon WRITE set_epsilon RESET reset_epsilon STORED false)
36 Q_PROPERTY(int minSize READ get_minSize WRITE set_minSize RESET reset_minSize STORED false) 38 Q_PROPERTY(int minSize READ get_minSize WRITE set_minSize RESET reset_minSize STORED false)
  39 +
  40 +public:
  41 + enum Approximation { None = CV_CHAIN_APPROX_NONE,
  42 + Simple = CV_CHAIN_APPROX_SIMPLE,
  43 + L1 = CV_CHAIN_APPROX_TC89_L1,
  44 + KCOS = CV_CHAIN_APPROX_TC89_KCOS };
  45 +
  46 +private:
  47 + BR_PROPERTY(Approximation, approximation, None)
37 BR_PROPERTY(float, epsilon, 0) 48 BR_PROPERTY(float, epsilon, 0)
38 BR_PROPERTY(int, minSize, 40) 49 BR_PROPERTY(int, minSize, 40)
39 50
@@ -45,7 +56,7 @@ class FillContoursTransform : public UntrainableTransform @@ -45,7 +56,7 @@ class FillContoursTransform : public UntrainableTransform
45 vector<Vec4i> hierarchy; 56 vector<Vec4i> hierarchy;
46 57
47 /// Find contours 58 /// Find contours
48 - findContours(src.m(), contours, hierarchy, CV_RETR_TREE, CV_CHAIN_APPROX_SIMPLE, Point(0, 0)); 59 + findContours(src.m(), contours, hierarchy, CV_RETR_TREE, approximation);
49 60
50 if (epsilon > 0) 61 if (epsilon > 0)
51 for(size_t i=0; i<contours.size(); i++) 62 for(size_t i=0; i<contours.size(); i++)