diff --git a/openbr/gui/rankretrieval.cpp b/openbr/gui/rankretrieval.cpp new file mode 100644 index 0000000..837ce7b --- /dev/null +++ b/openbr/gui/rankretrieval.cpp @@ -0,0 +1,136 @@ +#include "rankretrieval.h" + +#include + +#include +#include + +using namespace br; + +RankRetrieval::RankRetrieval(QWidget *parent) : + QWidget(parent) +{ + targetPath = Context::scratchPath(); +} + +void RankRetrieval::clear() +{ + +} + +// This should be changed to used algorithm.cpp +void RankRetrieval::setAlgorithm(const QString &algorithm) +{ + br_set_property("algorithm",qPrintable(algorithm)); +} + +void RankRetrieval::setTargetGallery(const File &file) +{ + target = file; + enroll(); +} + +void RankRetrieval::setTargetPath() +{ + targetPath = QFileDialog::getSaveFileName(this, "Specify Target Gallery...", targetPath, tr(".gal Files (*.gal)")); +} + +void RankRetrieval::setQueryGallery(const File &file) +{ + query = file; + + // Change this to the set algorithm + QSharedPointer transform = br::Transform::fromAlgorithm("FaceDetection+FaceRecognitionRegistration"); + Template queryTemplate(query); + queryTemplate >> *transform; + + emit newQueryFile(queryTemplate.file); +} + +void RankRetrieval::enroll() +{ + File targetGallery(targetPath + ".gal"); + targetGallery.set("append", true); + + enrollWatcher.setFuture(QtConcurrent::run(Enroll, targetGallery.flat(), target.flat())); +} + +void RankRetrieval::compare() +{ + +} + +void RankRetrieval::first() +{ + /*if (matches.isEmpty() || gridPage == 0 || comparing) return; + + gridPage = 0; + + emit clearSelection(); + + displayMugshots();*/ +} + +void RankRetrieval::previous() +{ + /*if (matches.isEmpty() || gridPage == 0 || comparing) return; + + gridPage--; + + emit clearSelection(); + + displayMugshots();*/ +} + +void RankRetrieval::next() +{ + /*if (matches.isEmpty() || matches.size() <= gridPage*gridSize+gridSize || comparing) return; + + gridPage++; + + emit clearSelection(); + + displayMugshots();*/ +} + +void RankRetrieval::last() +{ + /*if (matches.isEmpty() || gridPage == matches.size()/gridSize || comparing) return; + + gridPage = matches.size()/gridSize; + + emit clearSelection(); + + displayMugshots();*/ +} + +void RankRetrieval::setIndex(int index) +{ + +} + +void RankRetrieval::compareDone() +{ + /* + if (matches.isEmpty()) return; + + br::FileList displayMugshots; + QStringList labels; + + for(int i = gridPage*gridSize; i < gridPage*gridSize+gridSize; i++) { + if (i >= matches.size()) { + break; + } + + displayMugshots.push_back(matches[i]); + labels.push_back("Rank: " + QString::number(i+1) + "\nScore: " + QString::number(scores[i], 'f', 3)); + } + + if (index != -1) heatMap(index); + + emit newMugshotLineup(displayMugshots, index); + emit newFormat(targetFormat); + emit newLabels(labels);*/ +} + +#include "moc_rankretrieval.cpp" diff --git a/openbr/gui/rankretrieval.h b/openbr/gui/rankretrieval.h new file mode 100644 index 0000000..9548335 --- /dev/null +++ b/openbr/gui/rankretrieval.h @@ -0,0 +1,55 @@ +#ifndef BR_RANKRETRIEVAL_H +#define BR_RANKRETRIEVAL_H + +#include +#include +#include +#include + +namespace br { + +class BR_EXPORT RankRetrieval : public QWidget +{ + Q_OBJECT + + File target, query; + FileList targetFiles, queryFiles; + QList scores; + QFutureWatcher enrollWatcher; + QFutureWatcher compareWatcher; + + QString targetPath; + +public: + explicit RankRetrieval(QWidget *parent = 0); + +public slots: + void setAlgorithm(const QString &algorithm); + + void clear(); + void setIndex(int index); + void setTargetGallery(const File &file); + void setTargetPath(); + void setQueryGallery(const File &file); + + void first(); + void previous(); + void next(); + void last(); + + void compareDone(); + +signals: + void newTargetFileList(FileList file); + void newQueryFile(File file); + void newScore(float score); + +private: + void enroll(); + void compare(); + +}; + +} // namespace br + +#endif // BR_RANKRETRIEVAL_H