Commit 0a9dabbacc56e1264f4e7dc8a02891b4bbad5f72
1 parent
3591aa70
creating bounding boxes around points
Showing
1 changed file
with
58 additions
and
0 deletions
openbr/plugins/metadata/pointstorects.cpp
0 → 100644
| 1 | +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * | |
| 2 | + * Copyright 2015 Rank One Computing 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 For each point, add a rectangle with radius as a half width | |
| 25 | + * \author Brendan Klare \cite bklare | |
| 26 | + */ | |
| 27 | + | |
| 28 | +class PointsToRectsTransform : public UntrainableTransform | |
| 29 | +{ | |
| 30 | + Q_OBJECT | |
| 31 | + Q_PROPERTY(float radius READ get_radius WRITE set_radius RESET reset_radius STORED false) | |
| 32 | + Q_PROPERTY(bool clearRects READ get_clearRects WRITE set_clearRects RESET reset_clearRects STORED false) | |
| 33 | + BR_PROPERTY(float, radius, 4) | |
| 34 | + BR_PROPERTY(bool, clearRects, true) | |
| 35 | + | |
| 36 | + void project(const Template &src, Template &dst) const | |
| 37 | + { | |
| 38 | + dst = src; | |
| 39 | + | |
| 40 | + if (clearRects) | |
| 41 | + dst.file.clearRects(); | |
| 42 | + | |
| 43 | + if (src.file.points().isEmpty()) { | |
| 44 | + if (Globals->verbose) qWarning("No landmarks"); | |
| 45 | + return; | |
| 46 | + } | |
| 47 | + | |
| 48 | + for (int i = 0; i < src.file.points().size(); i++) { | |
| 49 | + dst.file.appendRect(QRectF(src.file.points()[i].x() - radius, src.file.points()[i].y() - radius, radius * 2, radius * 2)); | |
| 50 | + } | |
| 51 | + } | |
| 52 | +}; | |
| 53 | + | |
| 54 | +BR_REGISTER(Transform, PointsToRectsTransform) | |
| 55 | + | |
| 56 | +} // namespace br | |
| 57 | + | |
| 58 | +#include "metadata/pointstorects.moc" | ... | ... |