Commit 7857e5526da703fb8739cb1821e57d89d1a0c68f
1 parent
65949148
removed url format
Showing
1 changed file
with
0 additions
and
68 deletions
openbr/plugins/format/url.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 | - | ||
| 17 | -#include <QtNetwork> | ||
| 18 | -#include <opencv2/highgui/highgui.hpp> | ||
| 19 | - | ||
| 20 | -#include <openbr/plugins/openbr_internal.h> | ||
| 21 | - | ||
| 22 | -using namespace cv; | ||
| 23 | - | ||
| 24 | -namespace br | ||
| 25 | -{ | ||
| 26 | - | ||
| 27 | -/*! | ||
| 28 | - * \ingroup formats | ||
| 29 | - * \brief Reads image files from the web. | ||
| 30 | - * \author Josh Klontz \cite jklontz | ||
| 31 | - */ | ||
| 32 | -class urlFormat : public Format | ||
| 33 | -{ | ||
| 34 | - Q_OBJECT | ||
| 35 | - | ||
| 36 | - Template read() const | ||
| 37 | - { | ||
| 38 | - Template t; | ||
| 39 | - | ||
| 40 | - QNetworkAccessManager networkAccessManager; | ||
| 41 | - QNetworkRequest request(QString(file.name).remove(".url")); | ||
| 42 | - request.setAttribute(QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::AlwaysNetwork); | ||
| 43 | - QNetworkReply *reply = networkAccessManager.get(request); | ||
| 44 | - | ||
| 45 | - while (!reply->isFinished()) QCoreApplication::processEvents(); | ||
| 46 | - if (reply->error()) qWarning("%s (%s)", qPrintable(reply->errorString()), qPrintable(QString::number(reply->error()))); | ||
| 47 | - | ||
| 48 | - QByteArray data = reply->readAll(); | ||
| 49 | - delete reply; | ||
| 50 | - | ||
| 51 | - Mat m = imdecode(Mat(1, data.size(), CV_8UC1, data.data()), 1); | ||
| 52 | - if (m.data) t.append(m); | ||
| 53 | - | ||
| 54 | - return t; | ||
| 55 | - } | ||
| 56 | - | ||
| 57 | - void write(const Template &t) const | ||
| 58 | - { | ||
| 59 | - (void) t; | ||
| 60 | - qFatal("Not supported."); | ||
| 61 | - } | ||
| 62 | -}; | ||
| 63 | - | ||
| 64 | -BR_REGISTER(Format, urlFormat) | ||
| 65 | - | ||
| 66 | -} // namespace br | ||
| 67 | - | ||
| 68 | -#include "format/url.moc" |