Commit 79c13db8393446590f5b088ce8a7fb3b3e40a0b4

Authored by Josh Klontz
1 parent 93273b8a

remove draw segmentation

openbr/plugins/gui/drawsegmentation.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   -
19   -#include <opencv2/imgproc.hpp>
20   -
21   -using namespace std;
22   -using namespace cv;
23   -
24   -namespace br
25   -{
26   -
27   -/*!
28   - * \ingroup transforms
29   - * \brief Fill in the segmentations or draw a line between intersecting segments.
30   - * \author Austin Blanton \cite imaus10
31   - */
32   -class DrawSegmentation : public UntrainableTransform
33   -{
34   - Q_OBJECT
35   - Q_PROPERTY(bool fillSegment READ get_fillSegment WRITE set_fillSegment RESET reset_fillSegment STORED false)
36   - BR_PROPERTY(bool, fillSegment, true)
37   -
38   - void project(const Template &src, Template &dst) const
39   - {
40   - if (!src.file.contains("SegmentsMask") || !src.file.contains("NumSegments")) qFatal("Must supply a Contours object in the metadata to drawContours.");
41   - Mat segments = src.file.get<Mat>("SegmentsMask");
42   - int numSegments = src.file.get<int>("NumSegments");
43   -
44   - dst.file = src.file;
45   - Mat drawn = fillSegment ? Mat(segments.size(), CV_8UC3, Scalar::all(0)) : src.m();
46   -
47   - for (int i=1; i<numSegments+1; i++) {
48   - Mat mask = segments == i;
49   - if (fillSegment) { // color the whole segment
50   - // set to a random color - get ready for a craaaazy acid trip
51   - int b = theRNG().uniform(0, 255);
52   - int g = theRNG().uniform(0, 255);
53   - int r = theRNG().uniform(0, 255);
54   - drawn.setTo(Scalar(r,g,b), mask);
55   - } else { // draw lines where there's a color change
56   - vector<vector<Point> > contours;
57   - Scalar color(0,255,0);
58   - findContours(mask, contours, RETR_LIST, CHAIN_APPROX_NONE);
59   - drawContours(drawn, contours, -1, color);
60   - }
61   - }
62   -
63   - dst.m() = drawn;
64   - }
65   -};
66   -
67   -BR_REGISTER(Transform, DrawSegmentation)
68   -
69   -} // namespace br
70   -
71   -#include "gui/drawsegmentation.moc"