Commit 20b798c36d098fd47b889bd2513544bf717253b0

Authored by Keyur Patel
1 parent f8e38aa2

Revert "removed gallery compare transform"

This reverts commit 884a875154d76b7fcafe9d0a968d6cd44d431a33.
openbr/plugins/core/gallerycompare.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 +#include <openbr/core/opencvutils.h>
  19 +
  20 +namespace br
  21 +{
  22 +
  23 +/*!
  24 + * \ingroup transforms
  25 + * \brief Compare each Template to a fixed Gallery (with name = galleryName), using the specified distance.
  26 + * dst will contain a 1 by n vector of scores.
  27 + * \author Charles Otto \cite caotto
  28 + */
  29 +class GalleryCompareTransform : public Transform
  30 +{
  31 + Q_OBJECT
  32 + Q_PROPERTY(br::Distance *distance READ get_distance WRITE set_distance RESET reset_distance STORED true)
  33 + Q_PROPERTY(QString galleryName READ get_galleryName WRITE set_galleryName RESET reset_galleryName STORED false)
  34 + BR_PROPERTY(br::Distance*, distance, NULL)
  35 + BR_PROPERTY(QString, galleryName, "")
  36 +
  37 + TemplateList gallery;
  38 +
  39 + void project(const Template &src, Template &dst) const
  40 + {
  41 + dst = src;
  42 + if (gallery.isEmpty())
  43 + return;
  44 +
  45 + QList<float> line = distance->compare(gallery, src);
  46 + dst.m() = OpenCVUtils::toMat(line, 1);
  47 + }
  48 +
  49 + void init()
  50 + {
  51 + if (!galleryName.isEmpty())
  52 + gallery = TemplateList::fromGallery(galleryName);
  53 + }
  54 +
  55 + void train(const TemplateList &data)
  56 + {
  57 + gallery = data;
  58 + }
  59 +
  60 + void store(QDataStream &stream) const
  61 + {
  62 + br::Object::store(stream);
  63 + stream << gallery;
  64 + }
  65 +
  66 + void load(QDataStream &stream)
  67 + {
  68 + br::Object::load(stream);
  69 + stream >> gallery;
  70 + }
  71 +
  72 +public:
  73 + GalleryCompareTransform() : Transform(false, true) {}
  74 +};
  75 +
  76 +BR_REGISTER(Transform, GalleryCompareTransform)
  77 +
  78 +} // namespace br
  79 +
  80 +#include "core/gallerycompare.moc"
... ...