Commit bcf2d579ea3e1c7ae9a4acb4fe9265443743751b

Authored by Scott Klum
1 parent 2db5366c

Added filelist sorting by metadata key

app/openbr-gui/initialize.cpp
@@ -20,13 +20,13 @@ @@ -20,13 +20,13 @@
20 20
21 #include "initialize.h" 21 #include "initialize.h"
22 22
23 -void br_initialize_gui() 23 +void br_initialize_gui(const char *sdk_path)
24 { 24 {
25 Q_INIT_RESOURCE(icons); 25 Q_INIT_RESOURCE(icons);
26 qRegisterMetaType<br::File>("br::File"); 26 qRegisterMetaType<br::File>("br::File");
27 qRegisterMetaType<br::FileList>("br::FileList"); 27 qRegisterMetaType<br::FileList>("br::FileList");
28 qRegisterMetaType<br::Template>("br::Template"); 28 qRegisterMetaType<br::Template>("br::Template");
29 qRegisterMetaType<br::TemplateList>("br::TemplateList"); 29 qRegisterMetaType<br::TemplateList>("br::TemplateList");
30 - br_initialize_qt(); 30 + br_initialize_qt(sdk_path);
31 br_set_property("log", qPrintable(QString("%1/log.txt").arg(br_scratch_path()))); 31 br_set_property("log", qPrintable(QString("%1/log.txt").arg(br_scratch_path())));
32 } 32 }
app/openbr-gui/initialize.h
@@ -19,6 +19,6 @@ @@ -19,6 +19,6 @@
19 19
20 #include <openbr_export.h> 20 #include <openbr_export.h>
21 21
22 -BR_EXPORT_GUI void br_initialize_gui(); 22 +BR_EXPORT_GUI void br_initialize_gui(const char *sdk_path = "");
23 23
24 #endif // __INITIALIZE_H 24 #endif // __INITIALIZE_H
sdk/openbr_plugin.cpp
@@ -26,6 +26,8 @@ @@ -26,6 +26,8 @@
26 #endif // BR_DISTRIBUTED 26 #endif // BR_DISTRIBUTED
27 #include <openbr_plugin.h> 27 #include <openbr_plugin.h>
28 28
  29 +#include <algorithm>
  30 +
29 #include "version.h" 31 #include "version.h"
30 #include "core/bee.h" 32 #include "core/bee.h"
31 #include "core/common.h" 33 #include "core/common.h"
@@ -357,6 +359,38 @@ QStringList FileList::names() const @@ -357,6 +359,38 @@ QStringList FileList::names() const
357 return names; 359 return names;
358 } 360 }
359 361
  362 +typedef std::pair<std::string,int> metadataPair;
  363 +bool comparator( const metadataPair &l, const metadataPair &r)
  364 +{
  365 + return l.first < r.first;
  366 +}
  367 +
  368 +void FileList::sort(const QString& key)
  369 +{
  370 + std::vector<metadataPair> metadata;
  371 +
  372 + int i = 0;
  373 +
  374 + foreach (const File &file, *this)
  375 + {
  376 + metadataPair pair = std::make_pair(file.get(key).toString().toStdString().c_str(), i);
  377 + metadata.push_back(pair);
  378 + i++;
  379 + }
  380 +
  381 + std::sort(metadata.begin(), metadata.end(), comparator);
  382 +
  383 + for (int j = 0; j < metadata.size(); j++)
  384 + {
  385 + this->push_back(this->at(metadata[j].second));
  386 + }
  387 +
  388 + iterator half = this->begin();
  389 + half += metadata.size();
  390 +
  391 + this->erase(this->begin(), half);
  392 +}
  393 +
360 QList<float> FileList::labels() const 394 QList<float> FileList::labels() const
361 { 395 {
362 QList<float> labels; 396 QList<float> labels;
sdk/openbr_plugin.h
@@ -118,7 +118,7 @@ void reset_##NAME() { NAME = DEFAULT; } @@ -118,7 +118,7 @@ void reset_##NAME() { NAME = DEFAULT; }
118 * --- | ---- | ----------- 118 * --- | ---- | -----------
119 * path | QString | Resolve complete file paths from file names 119 * path | QString | Resolve complete file paths from file names
120 * enrollAll | bool | Enroll zero or more templates per file 120 * enrollAll | bool | Enroll zero or more templates per file
121 - * separator | QString | Sperate #name into multiple files 121 + * separator | QString | Seperate #name into multiple files
122 * Input_Index | int | Index of a template in a template list 122 * Input_Index | int | Index of a template in a template list
123 * Label | float | Classification/Regression class 123 * Label | float | Classification/Regression class
124 * Confidence | float | Classification/Regression quality 124 * Confidence | float | Classification/Regression quality
@@ -135,6 +135,7 @@ void reset_##NAME() { NAME = DEFAULT; } @@ -135,6 +135,7 @@ void reset_##NAME() { NAME = DEFAULT; }
135 * Yaw | float | Pose 135 * Yaw | float | Pose
136 * Landmarks | QList<QPointF> | Landmark list 136 * Landmarks | QList<QPointF> | Landmark list
137 * ROIs | QList<Rect> | Region Of Interest (ROI) list 137 * ROIs | QList<Rect> | Region Of Interest (ROI) list
  138 + * Age | QString | Age used for demographic filtering
138 * _* | * | Reserved for internal use 139 * _* | * | Reserved for internal use
139 */ 140 */
140 struct BR_EXPORT File 141 struct BR_EXPORT File
@@ -239,6 +240,7 @@ struct BR_EXPORT FileList : public QList&lt;File&gt; @@ -239,6 +240,7 @@ struct BR_EXPORT FileList : public QList&lt;File&gt;
239 240
240 QStringList flat() const; /*!< \brief Returns br::File::flat() for each file in the list. */ 241 QStringList flat() const; /*!< \brief Returns br::File::flat() for each file in the list. */
241 QStringList names() const; /*!< \brief Returns #br::File::name for each file in the list. */ 242 QStringList names() const; /*!< \brief Returns #br::File::name for each file in the list. */
  243 + void sort(const QString& key); /*!< \brief Sort the list based on metadata. */
242 QList<float> labels() const; /*!< \brief Returns br::File::label() for each file in the list. */ 244 QList<float> labels() const; /*!< \brief Returns br::File::label() for each file in the list. */
243 int failures() const; /*!< \brief Returns the number of files with br::File::failed(). */ 245 int failures() const; /*!< \brief Returns the number of files with br::File::failed(). */
244 }; 246 };
1 -Subproject commit 504960df12db25e09c39ab098fb8614c1db51617 1 +Subproject commit 1031e9e416427f5dd8e9f4e7ff4dd74632626c22