Commit 044fc4e6a9846c5f516767a715856607e3d7b13f
1 parent
c28d4b15
remove largestconvexarea
Showing
1 changed file
with
0 additions
and
59 deletions
openbr/plugins/imgproc/largestconvexarea.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 <opencv2/imgproc/imgproc.hpp> | |
| 18 | - | |
| 19 | -#include <openbr/plugins/openbr_internal.h> | |
| 20 | - | |
| 21 | -using namespace cv; | |
| 22 | - | |
| 23 | -namespace br | |
| 24 | -{ | |
| 25 | - | |
| 26 | -/*! | |
| 27 | - * \ingroup transforms | |
| 28 | - * \brief Set the template's label to the area of the largest convex hull. | |
| 29 | - * \author Josh Klontz \cite jklontz | |
| 30 | - */ | |
| 31 | -class LargestConvexAreaTransform : public UntrainableTransform | |
| 32 | -{ | |
| 33 | - Q_OBJECT | |
| 34 | - | |
| 35 | - Q_PROPERTY(QString outputVariable READ get_outputVariable WRITE set_outputVariable RESET reset_outputVariable STORED false) | |
| 36 | - BR_PROPERTY(QString, outputVariable, "Label") | |
| 37 | - | |
| 38 | - void project(const Template &src, Template &dst) const | |
| 39 | - { | |
| 40 | - std::vector< std::vector<Point> > contours; | |
| 41 | - findContours(src.m().clone(), contours, RETR_EXTERNAL, CHAIN_APPROX_SIMPLE); | |
| 42 | - double maxArea = 0; | |
| 43 | - foreach (const std::vector<Point> &contour, contours) { | |
| 44 | - std::vector<Point> hull; | |
| 45 | - convexHull(contour, hull); | |
| 46 | - double area = contourArea(contour); | |
| 47 | - double hullArea = contourArea(hull); | |
| 48 | - if (area / hullArea > 0.98) | |
| 49 | - maxArea = std::max(maxArea, area); | |
| 50 | - } | |
| 51 | - dst.file.set(outputVariable, maxArea); | |
| 52 | - } | |
| 53 | -}; | |
| 54 | - | |
| 55 | -BR_REGISTER(Transform, LargestConvexAreaTransform) | |
| 56 | - | |
| 57 | -} // namespace br | |
| 58 | - | |
| 59 | -#include "imgproc/largestconvexarea.moc" |