Commit 7861017706db9e461f17ef14943f189e1c525343

Authored by bklare
1 parent e1f199dc

Transform to filter bad face detections at train tim

openbr/plugins/metadata/verifydetection.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 Check if a the automated face detection contains the landmarks correpsonding
  25 + * to the tempate metadata. If not, drop the template. This is meant for use
  26 + * during training, where the landmarks will be ground truth'd. If one wants to
  27 + * using a ground truth bounding box instead, then convert the BB to a landmark.
  28 + * \br_property int index Index of the landmark to be used.
  29 + * \author Josh Klontz \cite jklontz
  30 + */
  31 +class VerifyDetectionTransform : public UntrainableTransform
  32 +{
  33 + Q_OBJECT
  34 + Q_PROPERTY(int index READ get_index WRITE set_index RESET reset_index STORED false)
  35 + BR_PROPERTY(int, index, 14)
  36 +
  37 + void project(const Template &src, Template &dst) const
  38 + {
  39 + qWarning("Single template project not supported by VerifyDetectionTransform.");
  40 + dst.file.fte = true;
  41 + }
  42 +
  43 + void project(const TemplateList &src, TemplateList &dst) const
  44 + {
  45 + for (int i = 0; i < src.size(); i++)
  46 + if (src[i].file.get<QRectF>("FrontalFace").contains(src[i].file.points()[index]))
  47 + dst.append(src[i]);
  48 + }
  49 +};
  50 +
  51 +BR_REGISTER(Transform, VerifyDetectionTransform)
  52 +
  53 +} // namespace br
  54 +
  55 +#include "metadata/verifydetection.moc"