Commit f2a2d07d6ad8115b16d8e46f248f534b8caa78b2

Authored by Josh Klontz
1 parent b423c532

remove readlandmarks

openbr/plugins/io/readlandmarks.cpp deleted
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 -#include <openbr/plugins/openbr_internal.h>  
17 -  
18 -  
19 -namespace br  
20 -{  
21 -  
22 -/*!  
23 - * \ingroup transforms  
24 - * \brief Read landmarks from a file and associate them with the correct Templates.  
25 - * \author Scott Klum \cite sklum  
26 - * \br_format Example of the format:  
27 - *  
28 - * image_001.jpg:146.000000,190.000000,227.000000,186.000000,202.000000,256.000000  
29 - * image_002.jpg:75.000000,235.000000,140.000000,225.000000,91.000000,300.000000  
30 - * image_003.jpg:158.000000,186.000000,246.000000,188.000000,208.000000,233.000000  
31 - *  
32 - */  
33 -class ReadLandmarksTransform : public UntrainableMetadataTransform  
34 -{  
35 - Q_OBJECT  
36 -  
37 - Q_PROPERTY(QString file READ get_file WRITE set_file RESET reset_file STORED false)  
38 - Q_PROPERTY(QString imageDelimiter READ get_imageDelimiter WRITE set_imageDelimiter RESET reset_imageDelimiter STORED false)  
39 - Q_PROPERTY(QString landmarkDelimiter READ get_landmarkDelimiter WRITE set_landmarkDelimiter RESET reset_landmarkDelimiter STORED false)  
40 - BR_PROPERTY(QString, file, QString())  
41 - BR_PROPERTY(QString, imageDelimiter, ":")  
42 - BR_PROPERTY(QString, landmarkDelimiter, ",")  
43 -  
44 - QHash<QString, QList<QPointF> > landmarks;  
45 -  
46 - void init()  
47 - {  
48 - if (file.isEmpty())  
49 - return;  
50 -  
51 - QFile f(file);  
52 - if (!f.open(QFile::ReadOnly | QFile::Text))  
53 - qFatal("Failed to open %s for reading.", qPrintable(f.fileName()));  
54 -  
55 - while (!f.atEnd()) {  
56 - const QStringList words = QString(f.readLine()).split(imageDelimiter);  
57 - const QStringList lm = words[1].split(landmarkDelimiter);  
58 -  
59 - QList<QPointF> points;  
60 - bool ok;  
61 - for (int i=0; i<lm.size(); i+=2)  
62 - points.append(QPointF(lm[i].toFloat(&ok),lm[i+1].toFloat(&ok)));  
63 - if (!ok) qFatal("Failed to read landmark.");  
64 -  
65 - landmarks.insert(words[0],points);  
66 - }  
67 - }  
68 -  
69 - void projectMetadata(const File &src, File &dst) const  
70 - {  
71 - dst = src;  
72 - dst.appendPoints(landmarks[dst.fileName()]);  
73 - }  
74 -};  
75 -  
76 -BR_REGISTER(Transform, ReadLandmarksTransform)  
77 -  
78 -} // namespace br  
79 -  
80 -#include "io/readlandmarks.moc"