diff --git a/app/CMakeLists.txt b/app/CMakeLists.txt index bf1be14..2769389 100644 --- a/app/CMakeLists.txt +++ b/app/CMakeLists.txt @@ -10,5 +10,7 @@ if(NOT ${BR_EMBEDDED}) add_subdirectory(br-crawl) add_subdirectory(br-enroll) add_subdirectory(br-gui) + add_subdirectory(br-print) add_subdirectory(br-search) + add_subdirectory(br-select) endif() diff --git a/app/br-crawl/br-crawl.cpp b/app/br-crawl/br-crawl.cpp index c6a51ca..0a9ec74 100644 --- a/app/br-crawl/br-crawl.cpp +++ b/app/br-crawl/br-crawl.cpp @@ -72,7 +72,7 @@ static void crawl(QFileInfo url, int currentDepth = 0) } else if (url.isFile()) { const QString suffix = url.suffix(); if ((suffix == "bmp") || (suffix == "jpg") || (suffix == "jpeg") || (suffix == "png") || (suffix == "tiff")) { - printf(json ? "{ URL = \"file://%s\" }\n" : "file://%s\n", qPrintable(url.canonicalFilePath())); + printf(json ? "{ \"URL\" : \"file://%s\" }\n" : "file://%s\n", qPrintable(url.canonicalFilePath())); fflush(stdout); currentImages++; } diff --git a/app/br-download/br-download.cpp b/app/br-download/br-download.cpp index f1b41b8..73d81d6 100644 --- a/app/br-download/br-download.cpp +++ b/app/br-download/br-download.cpp @@ -111,11 +111,18 @@ int main(int argc, char *argv[]) QFile file; file.open(stdin, QFile::ReadOnly); while (!file.atEnd()) { - const QByteArray line = file.readLine(); - process(json ? QJsonDocument::fromJson(line).object().value("URL").toString() - : QString::fromLocal8Bit(line), - json ? line.simplified() : QByteArray(), + const QByteArray line = file.readLine().simplified(); + if (line.isEmpty()) + continue; + + QJsonParseError error; + process(json ? QJsonDocument::fromJson(line, &error).object().value("URL").toString() + : QString::fromLatin1(line), + json ? line : QByteArray(), nam); + + if (error.error != QJsonParseError::NoError) + qDebug() << error.errorString(); } } diff --git a/app/br-print/CMakeLists.txt b/app/br-print/CMakeLists.txt new file mode 100644 index 0000000..c3bee4b --- /dev/null +++ b/app/br-print/CMakeLists.txt @@ -0,0 +1,4 @@ +add_executable(br-print br-print.cpp ${BR_RESOURCES}) +target_link_libraries(br-print openbr ${BR_THIRDPARTY_LIBS}) +qt5_use_modules(br-print ${QT_DEPENDENCIES}) +install(TARGETS br-print RUNTIME DESTINATION bin) diff --git a/app/br-print/br-print.cpp b/app/br-print/br-print.cpp new file mode 100644 index 0000000..58daaa8 --- /dev/null +++ b/app/br-print/br-print.cpp @@ -0,0 +1,44 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * 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 + +static void help() +{ + printf("br-print [args]\n" + "================\n" + "* __stdin__ - Templates\n" + "* __stdout__ - Template _data_\n" + "\n" + "_br-print_ extracts template data.\n"); +} + +static void print_utemplate(br_const_utemplate utemplate, br_callback_context) +{ + fwrite(utemplate->data, 1, utemplate->size, stdout); + printf("\n"); +} + +int main(int argc, char *argv[]) +{ + for (int i=1; ialgorithmID; + cout << "\", \"QueryImageID\":\""; writeMD5asHex(query->imageID); - cout << ", \"QueryTemplateID\"="; + cout << "\", \"QueryTemplateID\":\""; writeMD5asHex(query->templateID); + cout << "\""; printMetadata(query); - cout << ", \"Targets\"=[ "; + cout << ", \"Targets\":[ "; for (int i=topTargets.size()-1; i>=0; i--) { Target &target = topTargets[i]; - cout << "{ \"ImageID\"="; + cout << "{ \"ImageID\":\""; writeMD5asHex(target.second->imageID); - cout << ", \"TemplateID\"="; + cout << "\", \"TemplateID\":\""; writeMD5asHex(target.second->templateID); - cout << ", \"Score\"=" << target.first; + cout << "\", \"Score\":" << target.first; printMetadata(target.second); cout << " }"; if (i > 0) diff --git a/app/br-select/CMakeLists.txt b/app/br-select/CMakeLists.txt new file mode 100644 index 0000000..bdd383d --- /dev/null +++ b/app/br-select/CMakeLists.txt @@ -0,0 +1,4 @@ +add_executable(br-select br-select.cpp ${BR_RESOURCES}) +target_link_libraries(br-select openbr ${BR_THIRDPARTY_LIBS}) +qt5_use_modules(br-select ${QT_DEPENDENCIES}) +install(TARGETS br-select RUNTIME DESTINATION bin) diff --git a/app/br-select/br-select.cpp b/app/br-select/br-select.cpp new file mode 100644 index 0000000..c6887ce --- /dev/null +++ b/app/br-select/br-select.cpp @@ -0,0 +1,54 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * 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 + +static void help() +{ + printf("br-select [args]\n" + "================\n" + "* __stdin__ - Templates\n" + "* __stdout__ - Templates\n" + "\n" + "_br-select_ filters templates templates.\n" + "\n" + "Optional Arguments\n" + "------------------\n" + "* -algorithmID - Allow a specific algorithmID\n"); +} + +static int *algorithmID = NULL; + +static void select_utemplate(br_const_utemplate utemplate, br_callback_context) +{ + if (algorithmID && utemplate->algorithmID != *algorithmID) + return; + + br_append_utemplate(stdout, utemplate); +} + +int main(int argc, char *argv[]) +{ + for (int i=1; i