Commit baaa28f49f7d0c98fd7ee49f0c9ced3cb388104a

Authored by Josh Klontz
1 parent a41b885f

remove fillcontours

openbr/plugins/imgproc/fillcontours.cpp deleted
1   -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
2   - * Copyright 2012 The MITRE Corporation *
3   - * *
4   - * Licensed under the Apache License, Version 2.0 (the "License"); *
5   - * you may not use this file except in compliance with the License. *
6   - * You may obtain a copy of the License at *
7   - * *
8   - * http://www.apache.org/licenses/LICENSE-2.0 *
9   - * *
10   - * Unless required by applicable law or agreed to in writing, software *
11   - * distributed under the License is distributed on an "AS IS" BASIS, *
12   - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
13   - * See the License for the specific language governing permissions and *
14   - * limitations under the License. *
15   - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
16   -
17   -#include <openbr/plugins/openbr_internal.h>
18   -#include <openbr/core/opencvutils.h>
19   -#include <opencv2/imgproc/imgproc.hpp>
20   -
21   -using namespace cv;
22   -
23   -namespace br
24   -{
25   -
26   -/*!
27   - * \ingroup transforms
28   - * \brief Fills contours with white pixels.
29   - * \author Scott Klum \cite sklum
30   - */
31   -class FillContoursTransform : public UntrainableTransform
32   -{
33   - Q_OBJECT
34   -
35   - Q_ENUMS(Approximation)
36   - Q_PROPERTY(Approximation approximation READ get_approximation WRITE set_approximation RESET reset_approximation STORED false)
37   - Q_PROPERTY(float epsilon READ get_epsilon WRITE set_epsilon RESET reset_epsilon 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 = CHAIN_APPROX_NONE,
42   - Simple = CHAIN_APPROX_SIMPLE,
43   - L1 = CHAIN_APPROX_TC89_L1,
44   - KCOS = CHAIN_APPROX_TC89_KCOS };
45   -
46   -private:
47   - BR_PROPERTY(Approximation, approximation, None)
48   - BR_PROPERTY(float, epsilon, 0)
49   - BR_PROPERTY(int, minSize, 40)
50   -
51   - void project(const Template &src, Template &dst) const
52   - {
53   - dst.m() = Mat::zeros(src.m().rows,src.m().cols,src.m().type());
54   -
55   - std::vector<std::vector<Point> > contours;
56   - std::vector<Vec4i> hierarchy;
57   -
58   - /// Find contours
59   - findContours(src.m(), contours, hierarchy, RETR_TREE, approximation);
60   -
61   - if (epsilon > 0)
62   - for(size_t i=0; i<contours.size(); i++)
63   - approxPolyDP(Mat(contours[i]), contours[i], epsilon, true);
64   -
65   - for(size_t i=0; i<contours.size(); i++)
66   - if (contours[i].size() > (size_t)minSize)
67   - drawContours(dst.m(), contours, i, Scalar(255,255,255), FILLED);
68   - }
69   -};
70   -
71   -BR_REGISTER(Transform, FillContoursTransform)
72   -
73   -} // namespace br
74   -
75   -#include "imgproc/fillcontours.moc"
76   -