diff --git a/app/CMakeLists.txt b/app/CMakeLists.txt index 81552e0..1e94ed9 100644 --- a/app/CMakeLists.txt +++ b/app/CMakeLists.txt @@ -6,7 +6,6 @@ add_subdirectory(examples) # Build additional OpenBR utilities if(NOT ${BR_EMBEDDED}) - add_subdirectory(br-download) add_subdirectory(br-crawl) add_subdirectory(br-gui) add_subdirectory(br-search) diff --git a/app/br-download/CMakeLists.txt b/app/br-download/CMakeLists.txt deleted file mode 100644 index 5cf6e73..0000000 --- a/app/br-download/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -add_executable(br-download br-download.cpp ${BR_RESOURCES}) -target_link_libraries(br-download openbr ${BR_THIRDPARTY_LIBS}) -qt5_use_modules(br-download ${QT_DEPENDENCIES}) -install(TARGETS br-download RUNTIME DESTINATION bin) diff --git a/app/br-download/br-download.cpp b/app/br-download/br-download.cpp deleted file mode 100644 index 6fd6e03..0000000 --- a/app/br-download/br-download.cpp +++ /dev/null @@ -1,130 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - * Copyright 2014 Noblis * - * * - * Licensed under the Apache License, Version 2.0 (the "License"); * - * you may not use this file except in compliance with the License. * - * You may obtain a copy of the License at * - * * - * http://www.apache.org/licenses/LICENSE-2.0 * - * * - * Unless required by applicable law or agreed to in writing, software * - * distributed under the License is distributed on an "AS IS" BASIS, * - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * - * See the License for the specific language governing permissions and * - * limitations under the License. * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -#include -#include -#include -#include -#include -#include -#include - -using namespace cv; -using namespace std; - -static void help() -{ - printf("br-download [URL] [args]\n" - "========================\n" - "* __stdin__ - URLs/JSON\n" - "* __stdout__ - Templates (raw data)\n" - "\n" - "_br-download_ retrieves and verifies the contents of an image URL.\n" - "If no URL is provided, download reads newline-separated image URLs from _stdin_.\n" - "Download writes templates containing the contents of the URL to _stdout_.\n" - "\n" - "Download is expected to filter out URLs that are not valid images.\n" - "Download may do this by checking the file header or decoding the file.\n" - "\n" - "Optional Arguments\n" - "------------------\n" - "* -help - Print usage information.\n" - "* -json - Input JSON instead of URLs.\n" - "* -permissive - Do not attempt to verify the contents of an image URL (verify otherwise).\n"); -} - -static bool json = false; -static bool permissive = false; -static bool url_provided = false; - -static void process(QString url, const QByteArray &metadata, QNetworkAccessManager &nam) -{ - url = url.simplified(); - if (url.isEmpty()) - return; - - if (url.startsWith("file://")) - url = url.mid(7); - - QIODevice *device = NULL; - if (QFileInfo(url).exists()) { - device = new QFile(url); - device->open(QIODevice::ReadOnly); - } else { - QNetworkReply *reply = nam.get(QNetworkRequest(url)); - while (!reply->isFinished()) - QCoreApplication::processEvents(); - - if (reply->error() != QNetworkReply::NoError) { - qDebug() << reply->errorString() << url; - reply->deleteLater(); - } else { - device = reply; - } - } - - if (!device) - return; - - const QByteArray data = device->readAll(); - delete device; - device = NULL; - - if (!permissive && imdecode(Mat(1, data.size(), CV_8UC1, (void*)data.data()), IMREAD_ANYDEPTH | IMREAD_ANYCOLOR).empty()) - return; - - const QByteArray hash = QCryptographicHash::hash(data, QCryptographicHash::Md5); - br_append_utemplate_contents(stdout, reinterpret_cast(hash.data()), reinterpret_cast(hash.data()), 3, data.size(), reinterpret_cast(data.data())); - - if (!metadata.isEmpty()) { - const QByteArray metadataHash = QCryptographicHash::hash(metadata, QCryptographicHash::Md5); - br_append_utemplate_contents(stdout, reinterpret_cast(hash.data()), reinterpret_cast(metadataHash.data()), 2, metadata.size() + 1 /* include null terminator */, reinterpret_cast(metadata.data())); - } -} - -int main(int argc, char *argv[]) -{ - QCoreApplication application(argc, argv); - QNetworkAccessManager nam; - - for (int i=1; i