Commit a7b975a9a18d85abbd313f0502ad9824c489db09

Authored by Scott Klum
1 parent 147f9ea1

Added rank retrieval mediator

openbr/gui/rankretrieval.cpp 0 → 100644
  1 +#include "rankretrieval.h"
  2 +
  3 +#include <QtConcurrent>
  4 +
  5 +#include <openbr/openbr.h>
  6 +#include <openbr/gui/faceviewer.h>
  7 +
  8 +using namespace br;
  9 +
  10 +RankRetrieval::RankRetrieval(QWidget *parent) :
  11 + QWidget(parent)
  12 +{
  13 + targetPath = Context::scratchPath();
  14 +}
  15 +
  16 +void RankRetrieval::clear()
  17 +{
  18 +
  19 +}
  20 +
  21 +// This should be changed to used algorithm.cpp
  22 +void RankRetrieval::setAlgorithm(const QString &algorithm)
  23 +{
  24 + br_set_property("algorithm",qPrintable(algorithm));
  25 +}
  26 +
  27 +void RankRetrieval::setTargetGallery(const File &file)
  28 +{
  29 + target = file;
  30 + enroll();
  31 +}
  32 +
  33 +void RankRetrieval::setTargetPath()
  34 +{
  35 + targetPath = QFileDialog::getSaveFileName(this, "Specify Target Gallery...", targetPath, tr(".gal Files (*.gal)"));
  36 +}
  37 +
  38 +void RankRetrieval::setQueryGallery(const File &file)
  39 +{
  40 + query = file;
  41 +
  42 + // Change this to the set algorithm
  43 + QSharedPointer<Transform> transform = br::Transform::fromAlgorithm("FaceDetection+FaceRecognitionRegistration");
  44 + Template queryTemplate(query);
  45 + queryTemplate >> *transform;
  46 +
  47 + emit newQueryFile(queryTemplate.file);
  48 +}
  49 +
  50 +void RankRetrieval::enroll()
  51 +{
  52 + File targetGallery(targetPath + ".gal");
  53 + targetGallery.set("append", true);
  54 +
  55 + enrollWatcher.setFuture(QtConcurrent::run(Enroll, targetGallery.flat(), target.flat()));
  56 +}
  57 +
  58 +void RankRetrieval::compare()
  59 +{
  60 +
  61 +}
  62 +
  63 +void RankRetrieval::first()
  64 +{
  65 + /*if (matches.isEmpty() || gridPage == 0 || comparing) return;
  66 +
  67 + gridPage = 0;
  68 +
  69 + emit clearSelection();
  70 +
  71 + displayMugshots();*/
  72 +}
  73 +
  74 +void RankRetrieval::previous()
  75 +{
  76 + /*if (matches.isEmpty() || gridPage == 0 || comparing) return;
  77 +
  78 + gridPage--;
  79 +
  80 + emit clearSelection();
  81 +
  82 + displayMugshots();*/
  83 +}
  84 +
  85 +void RankRetrieval::next()
  86 +{
  87 + /*if (matches.isEmpty() || matches.size() <= gridPage*gridSize+gridSize || comparing) return;
  88 +
  89 + gridPage++;
  90 +
  91 + emit clearSelection();
  92 +
  93 + displayMugshots();*/
  94 +}
  95 +
  96 +void RankRetrieval::last()
  97 +{
  98 + /*if (matches.isEmpty() || gridPage == matches.size()/gridSize || comparing) return;
  99 +
  100 + gridPage = matches.size()/gridSize;
  101 +
  102 + emit clearSelection();
  103 +
  104 + displayMugshots();*/
  105 +}
  106 +
  107 +void RankRetrieval::setIndex(int index)
  108 +{
  109 +
  110 +}
  111 +
  112 +void RankRetrieval::compareDone()
  113 +{
  114 + /*
  115 + if (matches.isEmpty()) return;
  116 +
  117 + br::FileList displayMugshots;
  118 + QStringList labels;
  119 +
  120 + for(int i = gridPage*gridSize; i < gridPage*gridSize+gridSize; i++) {
  121 + if (i >= matches.size()) {
  122 + break;
  123 + }
  124 +
  125 + displayMugshots.push_back(matches[i]);
  126 + labels.push_back("Rank: " + QString::number(i+1) + "\nScore: " + QString::number(scores[i], 'f', 3));
  127 + }
  128 +
  129 + if (index != -1) heatMap(index);
  130 +
  131 + emit newMugshotLineup(displayMugshots, index);
  132 + emit newFormat(targetFormat);
  133 + emit newLabels(labels);*/
  134 +}
  135 +
  136 +#include "moc_rankretrieval.cpp"
openbr/gui/rankretrieval.h 0 → 100644
  1 +#ifndef BR_RANKRETRIEVAL_H
  2 +#define BR_RANKRETRIEVAL_H
  3 +
  4 +#include <QFutureWatcher>
  5 +#include <QFileDialog>
  6 +#include <openbr/openbr_plugin.h>
  7 +#include <openbr/gui/faceviewer.h>
  8 +
  9 +namespace br {
  10 +
  11 +class BR_EXPORT RankRetrieval : public QWidget
  12 +{
  13 + Q_OBJECT
  14 +
  15 + File target, query;
  16 + FileList targetFiles, queryFiles;
  17 + QList<float> scores;
  18 + QFutureWatcher<void> enrollWatcher;
  19 + QFutureWatcher<void> compareWatcher;
  20 +
  21 + QString targetPath;
  22 +
  23 +public:
  24 + explicit RankRetrieval(QWidget *parent = 0);
  25 +
  26 +public slots:
  27 + void setAlgorithm(const QString &algorithm);
  28 +
  29 + void clear();
  30 + void setIndex(int index);
  31 + void setTargetGallery(const File &file);
  32 + void setTargetPath();
  33 + void setQueryGallery(const File &file);
  34 +
  35 + void first();
  36 + void previous();
  37 + void next();
  38 + void last();
  39 +
  40 + void compareDone();
  41 +
  42 +signals:
  43 + void newTargetFileList(FileList file);
  44 + void newQueryFile(File file);
  45 + void newScore(float score);
  46 +
  47 +private:
  48 + void enroll();
  49 + void compare();
  50 +
  51 +};
  52 +
  53 +} // namespace br
  54 +
  55 +#endif // BR_RANKRETRIEVAL_H