Commit 7629454e7920d52a0d4538150ec811672b3e74a1

Authored by Scott Klum
1 parent f17baf81

Fixes to enable building with BR_EMBEDDED

openbr/core/utility.cpp 0 → 100644
  1 +#include <openbr/core/qtutils.h>
  2 +#include "utility.h"
  3 +
  4 +QStringList br::getFiles(QDir dir, bool recursive)
  5 +{
  6 + dir = QDir(dir.canonicalPath());
  7 +
  8 + QStringList files;
  9 + foreach (const QString &file, QtUtils::naturalSort(dir.entryList(QDir::Files)))
  10 + files.append(dir.absoluteFilePath(file));
  11 +
  12 + if (!recursive) return files;
  13 +
  14 + foreach (const QString &folder, QtUtils::naturalSort(dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot))) {
  15 + QDir subdir(dir);
  16 + bool success = subdir.cd(folder); if (!success) qFatal("cd failure.");
  17 + files.append(getFiles(subdir, true));
  18 + }
  19 + return files;
  20 +}
  21 +
  22 +QStringList br::getFiles(const QString &regexp)
  23 +{
  24 + QFileInfo fileInfo(regexp);
  25 + QDir dir(fileInfo.dir());
  26 + QRegExp re(fileInfo.fileName());
  27 + re.setPatternSyntax(QRegExp::Wildcard);
  28 +
  29 + QStringList files;
  30 + foreach (const QString &fileName, dir.entryList(QDir::Files))
  31 + if (re.exactMatch(fileName))
  32 + files.append(dir.filePath(fileName));
  33 + return files;
  34 +}
... ...
openbr/core/utility.h 0 → 100644
  1 +#ifndef BR_CORE_UTILITY_H
  2 +#define BR_CORE_UTILITY_H
  3 +
  4 +#include <QStringList>
  5 +#include <QDir>
  6 +
  7 +#include <opencv2/core/core.hpp>
  8 +#include <openbr/openbr_export.h>
  9 +
  10 +namespace br
  11 +{
  12 +
  13 +BR_EXPORT QStringList getFiles(QDir dir, bool recursive);
  14 +BR_EXPORT QStringList getFiles(const QString &regexp);
  15 +
  16 +} // namespace br
  17 +
  18 +#endif // BR_CORE_UTILITY_H
... ...
openbr/gui/utility.cpp
... ... @@ -3,7 +3,6 @@
3 3 #include <assert.h>
4 4 #include <opencv2/imgproc/imgproc.hpp>
5 5 #include <opencv2/imgproc/imgproc_c.h>
6   -#include <openbr/core/qtutils.h>
7 6 #include "utility.h"
8 7  
9 8 using namespace cv;
... ... @@ -46,35 +45,3 @@ QImage br::toQImage(const Mat &amp;mat)
46 45  
47 46 return QImage(mat8uc3.data, mat8uc3.cols, mat8uc3.rows, 3*mat8uc3.cols, QImage::Format_RGB888).copy();
48 47 }
49   -
50   -QStringList br::getFiles(QDir dir, bool recursive)
51   -{
52   - dir = QDir(dir.canonicalPath());
53   -
54   - QStringList files;
55   - foreach (const QString &file, QtUtils::naturalSort(dir.entryList(QDir::Files)))
56   - files.append(dir.absoluteFilePath(file));
57   -
58   - if (!recursive) return files;
59   -
60   - foreach (const QString &folder, QtUtils::naturalSort(dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot))) {
61   - QDir subdir(dir);
62   - bool success = subdir.cd(folder); if (!success) qFatal("cd failure.");
63   - files.append(getFiles(subdir, true));
64   - }
65   - return files;
66   -}
67   -
68   -QStringList br::getFiles(const QString &regexp)
69   -{
70   - QFileInfo fileInfo(regexp);
71   - QDir dir(fileInfo.dir());
72   - QRegExp re(fileInfo.fileName());
73   - re.setPatternSyntax(QRegExp::Wildcard);
74   -
75   - QStringList files;
76   - foreach (const QString &fileName, dir.entryList(QDir::Files))
77   - if (re.exactMatch(fileName))
78   - files.append(dir.filePath(fileName));
79   - return files;
80   -}
... ...
openbr/gui/utility.h
1   -#ifndef BR_UTILITY_H
2   -#define BR_UTILITY_H
  1 +#ifndef BR_GUI_UTILITY_H
  2 +#define BR_GUI_UTILITY_H
3 3  
4 4 #include <QImage>
5 5 #include <QStringList>
... ... @@ -12,9 +12,7 @@ namespace br
12 12 {
13 13  
14 14 BR_EXPORT QImage toQImage(const cv::Mat &mat);
15   -BR_EXPORT QStringList getFiles(QDir dir, bool recursive);
16   -BR_EXPORT QStringList getFiles(const QString &regexp);
17 15  
18 16 } // namespace br
19 17  
20   -#endif // BR_UTILITY_H
  18 +#endif // BR_GUI_UTILITY_H
... ...
openbr/plugins/gallery/db.cpp
... ... @@ -14,7 +14,9 @@
14 14 * limitations under the License. *
15 15 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
16 16  
  17 +#ifndef BR_EMBEDDED
17 18 #include <QtSql>
  19 +#endif // BR_EMBEDDED
18 20  
19 21 #include <openbr/plugins/openbr_internal.h>
20 22 #include <openbr/core/qtutils.h>
... ...
openbr/plugins/gallery/empty.cpp
... ... @@ -18,7 +18,7 @@
18 18  
19 19 #include <openbr/plugins/openbr_internal.h>
20 20 #include <openbr/core/qtutils.h>
21   -#include <openbr/gui/utility.h>
  21 +#include <openbr/core/utility.h>
22 22  
23 23 namespace br
24 24 {
... ...
openbr/plugins/gallery/xml.cpp
... ... @@ -14,7 +14,9 @@
14 14 * limitations under the License. *
15 15 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
16 16  
  17 +#ifndef BR_EMBEDDED
17 18 #include <QtXml>
  19 +#endif // BR_EMBEDDED
18 20  
19 21 #include <openbr/plugins/openbr_internal.h>
20 22 #include <openbr/core/bee.h>
... ... @@ -36,10 +38,12 @@ class xmlGallery : public FileGallery
36 38 BR_PROPERTY(bool, skipMissing, false)
37 39 FileList files;
38 40  
  41 +#ifndef BR_EMBEDDED
39 42 QXmlStreamReader reader;
  43 + bool signatureActive;
  44 +#endif // BR_EMBEDDED
40 45  
41 46 QString currentSignatureName;
42   - bool signatureActive;
43 47  
44 48 ~xmlGallery()
45 49 {
... ... @@ -50,15 +54,17 @@ class xmlGallery : public FileGallery
50 54  
51 55 TemplateList readBlock(bool *done)
52 56 {
  57 + TemplateList templates;
  58 +
  59 +#ifndef BR_EMBEDDED
  60 + qint64 count = 0;
  61 +
53 62 if (readOpen())
54 63 reader.setDevice(&f);
55 64  
56 65 if (reader.atEnd())
57 66 f.seek(0);
58 67  
59   - TemplateList templates;
60   - qint64 count = 0;
61   -
62 68 while (!reader.atEnd())
63 69 {
64 70 // if an identity is active we try to read presentations
... ... @@ -169,8 +175,9 @@ class xmlGallery : public FileGallery
169 175 }
170 176 }
171 177 }
172   - *done = true;
  178 +#endif // BR_EMBEDDED
173 179  
  180 + *done = true;
174 181 return templates;
175 182 }
176 183  
... ...