Commit dc7df56391ec330c030c8393f894eb363e5f84a3
Merge branch 'master' of https://github.com/biometrics/openbr
Showing
3 changed files
with
19 additions
and
4 deletions
openbr/plugins/gallery/binary.cpp
| @@ -16,6 +16,7 @@ | @@ -16,6 +16,7 @@ | ||
| 16 | 16 | ||
| 17 | #include <QJsonObject> | 17 | #include <QJsonObject> |
| 18 | #include <QJsonParseError> | 18 | #include <QJsonParseError> |
| 19 | +#include <QUrl> | ||
| 19 | 20 | ||
| 20 | #ifdef _WIN32 | 21 | #ifdef _WIN32 |
| 21 | #include <io.h> | 22 | #include <io.h> |
| @@ -272,7 +273,8 @@ class utGallery : public BinaryGallery | @@ -272,7 +273,8 @@ class utGallery : public BinaryGallery | ||
| 272 | t.append(cv::Mat(1, dataSize, CV_8UC1, dataStart).clone() /* We don't want a shallow copy! */); | 273 | t.append(cv::Mat(1, dataSize, CV_8UC1, dataStart).clone() /* We don't want a shallow copy! */); |
| 273 | } else { | 274 | } else { |
| 274 | if (!gallery.atEnd()) | 275 | if (!gallery.atEnd()) |
| 275 | - qFatal("Failed to read universal template header!"); | 276 | + qWarning("Failed to read universal template header!"); |
| 277 | + gallery.close(); | ||
| 276 | } | 278 | } |
| 277 | return t; | 279 | return t; |
| 278 | } | 280 | } |
| @@ -284,7 +286,10 @@ class utGallery : public BinaryGallery | @@ -284,7 +286,10 @@ class utGallery : public BinaryGallery | ||
| 284 | qFatal("Expected 16-byte ImageID, got: %d bytes.", imageID.size()); | 286 | qFatal("Expected 16-byte ImageID, got: %d bytes.", imageID.size()); |
| 285 | 287 | ||
| 286 | const int32_t algorithmID = (t.isEmpty() || t.file.fte) ? 0 : t.file.get<int32_t>("AlgorithmID"); | 288 | const int32_t algorithmID = (t.isEmpty() || t.file.fte) ? 0 : t.file.get<int32_t>("AlgorithmID"); |
| 287 | - const QByteArray url = t.file.get<QString>("URL", t.file.name).toLatin1(); | 289 | + |
| 290 | + // QUrl::fromUserInput provides some nice functionality in terms of completing URLs | ||
| 291 | + // e.g. C:/test.jpg -> file://C:/test.jpg and google.com/image.jpg -> http://google.com/image.jpg | ||
| 292 | + const QByteArray url = QUrl::fromUserInput(t.file.get<QString>("URL", t.file.name)).toEncoded(); | ||
| 288 | 293 | ||
| 289 | int32_t x = 0, y = 0; | 294 | int32_t x = 0, y = 0; |
| 290 | uint32_t width = 0, height = 0; | 295 | uint32_t width = 0, height = 0; |
openbr/plugins/gallery/empty.cpp
| @@ -40,7 +40,12 @@ class EmptyGallery : public Gallery | @@ -40,7 +40,12 @@ class EmptyGallery : public Gallery | ||
| 40 | { | 40 | { |
| 41 | QDir dir(file.name); | 41 | QDir dir(file.name); |
| 42 | QtUtils::touchDir(dir); | 42 | QtUtils::touchDir(dir); |
| 43 | - gallerySize = dir.count(); | 43 | + QDirIterator it(dir.absolutePath(), QDir::Files | QDir::NoDotAndDotDot, QDirIterator::Subdirectories); |
| 44 | + gallerySize = 0; | ||
| 45 | + while (it.hasNext()) { | ||
| 46 | + it.next(); | ||
| 47 | + gallerySize++; | ||
| 48 | + } | ||
| 44 | } | 49 | } |
| 45 | 50 | ||
| 46 | TemplateList readBlock(bool *done) | 51 | TemplateList readBlock(bool *done) |
openbr/plugins/io/download.cpp
| @@ -57,7 +57,12 @@ private: | @@ -57,7 +57,12 @@ private: | ||
| 57 | if (!url.contains("://")) | 57 | if (!url.contains("://")) |
| 58 | url = "file://" + url; | 58 | url = "file://" + url; |
| 59 | dst.file.set("URL", url); | 59 | dst.file.set("URL", url); |
| 60 | - if (url.startsWith("file://")) | 60 | + |
| 61 | + static const QRegularExpression regExp("file:///[A-Z]:/"); | ||
| 62 | + | ||
| 63 | + if (url.contains(regExp)) | ||
| 64 | + url = url.mid(8); | ||
| 65 | + else if (url.startsWith("file://")) | ||
| 61 | url = url.mid(7); | 66 | url = url.mid(7); |
| 62 | 67 | ||
| 63 | QIODevice *device = NULL; | 68 | QIODevice *device = NULL; |