Commit 54dfb088b3f0b4de4acc85f4baa6593aa71a3e81
1 parent
20b798c3
Revert "remove namelandmarks"
This reverts commit 800affe84f8205d6ea7f88da00f90ac54a002b7f.
Showing
1 changed file
with
67 additions
and
0 deletions
openbr/plugins/metadata/namelandmarks.cpp
0 → 100644
| 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 | +namespace br | |
| 20 | +{ | |
| 21 | + | |
| 22 | +/*! | |
| 23 | + * \ingroup transforms | |
| 24 | + * \brief Name a point/rect | |
| 25 | + * \author Scott Klum \cite sklum | |
| 26 | + */ | |
| 27 | +class NameLandmarksTransform : public UntrainableMetadataTransform | |
| 28 | +{ | |
| 29 | + Q_OBJECT | |
| 30 | + Q_PROPERTY(bool point READ get_point WRITE set_point RESET reset_point STORED false) | |
| 31 | + BR_PROPERTY(bool, point, true) | |
| 32 | + Q_PROPERTY(QList<int> indices READ get_indices WRITE set_indices RESET reset_indices STORED false) | |
| 33 | + Q_PROPERTY(QStringList names READ get_names WRITE set_names RESET reset_names STORED false) | |
| 34 | + BR_PROPERTY(QList<int>, indices, QList<int>()) | |
| 35 | + BR_PROPERTY(QStringList, names, QStringList()) | |
| 36 | + | |
| 37 | + void projectMetadata(const File &src, File &dst) const | |
| 38 | + { | |
| 39 | + const bool makeList = indices.size() != names.size(); | |
| 40 | + | |
| 41 | + dst = src; | |
| 42 | + | |
| 43 | + if (point) { | |
| 44 | + QList<QPointF> points = src.points(); | |
| 45 | + | |
| 46 | + if (makeList) | |
| 47 | + dst.setList(names.first(),points); | |
| 48 | + else | |
| 49 | + for (int i=0; i<indices.size(); i++) | |
| 50 | + if (indices[i] < points.size()) dst.set(names[i], points[indices[i]]); | |
| 51 | + else qFatal("Index out of range."); | |
| 52 | + } else { | |
| 53 | + QList<QRectF> rects = src.rects(); | |
| 54 | + | |
| 55 | + for (int i=0; i<indices.size(); i++) { | |
| 56 | + if (indices[i] < rects.size()) dst.set(names[i], rects[indices[i]]); | |
| 57 | + else qFatal("Index out of range."); | |
| 58 | + } | |
| 59 | + } | |
| 60 | + } | |
| 61 | +}; | |
| 62 | + | |
| 63 | +BR_REGISTER(Transform, NameLandmarksTransform) | |
| 64 | + | |
| 65 | +} // namespace br | |
| 66 | + | |
| 67 | +#include "metadata/namelandmarks.moc" | ... | ... |