Commit 58ce287645b5ec3bfe1996837c3caab164cb4404
1 parent
912d806d
implemented landmarksGallery
Showing
1 changed file
with
44 additions
and
0 deletions
openbr/plugins/gallery.cpp
| @@ -870,6 +870,50 @@ class FDDBGallery : public Gallery | @@ -870,6 +870,50 @@ class FDDBGallery : public Gallery | ||
| 870 | 870 | ||
| 871 | BR_REGISTER(Gallery, FDDBGallery) | 871 | BR_REGISTER(Gallery, FDDBGallery) |
| 872 | 872 | ||
| 873 | +/*! | ||
| 874 | + * \ingroup galleries | ||
| 875 | + * \brief Text format for associating anonymous landmarks with images. | ||
| 876 | + * \author Josh Klontz \cite jklontz | ||
| 877 | + * | ||
| 878 | + * \code | ||
| 879 | + * file_name:x1,y1,x2,y2,...,xn,yn | ||
| 880 | + * file_name:x1,y1,x2,y2,...,xn,yn | ||
| 881 | + * ... | ||
| 882 | + * file_name:x1,y1,x2,y2,...,xn,yn | ||
| 883 | + * \endcode | ||
| 884 | + */ | ||
| 885 | +class landmarksGallery : public Gallery | ||
| 886 | +{ | ||
| 887 | + Q_OBJECT | ||
| 888 | + | ||
| 889 | + TemplateList readBlock(bool *done) | ||
| 890 | + { | ||
| 891 | + *done = true; | ||
| 892 | + TemplateList templates; | ||
| 893 | + foreach (const QString &line, QtUtils::readLines(file)) { | ||
| 894 | + const QStringList words = line.split(':'); | ||
| 895 | + if (words.size() != 2) qFatal("Expected exactly one ':' in: %s.", qPrintable(line)); | ||
| 896 | + File file(words[0]); | ||
| 897 | + const QList<float> vals = QtUtils::toFloats(words[1].split(',')); | ||
| 898 | + if (vals.size() % 2 != 0) qFatal("Expected an even number of comma-separated values."); | ||
| 899 | + QList<QPointF> points; points.reserve(vals.size()/2); | ||
| 900 | + for (int i=0; i<vals.size(); i+=2) | ||
| 901 | + points.append(QPointF(vals[i], vals[i+1])); | ||
| 902 | + file.setPoints(points); | ||
| 903 | + templates.append(file); | ||
| 904 | + } | ||
| 905 | + return templates; | ||
| 906 | + } | ||
| 907 | + | ||
| 908 | + void write(const Template &t) | ||
| 909 | + { | ||
| 910 | + (void) t; | ||
| 911 | + qFatal("Not implemented."); | ||
| 912 | + } | ||
| 913 | +}; | ||
| 914 | + | ||
| 915 | +BR_REGISTER(Gallery, landmarksGallery) | ||
| 916 | + | ||
| 873 | } // namespace br | 917 | } // namespace br |
| 874 | 918 | ||
| 875 | #include "gallery.moc" | 919 | #include "gallery.moc" |