-
Notifications
You must be signed in to change notification settings - Fork 798
Openbr docs app #641
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Openbr docs app #641
Changes from all commits
1b9174c
3f8e3a9
60310dc
2b6ef0e
a3b7524
15b7446
19ae014
db2f94d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| include_directories(${CMAKE_CURRENT_BINARY_DIR}) | ||
| add_executable(br-docs br-docs.cpp ${BR_RESOURCES}) | ||
|
|
||
| foreach(QT_DEPENDENCY IN LISTS QT_DEPENDENCIES) | ||
| target_link_libraries(br-docs "Qt6::${QT_DEPENDENCY}") | ||
| endforeach() | ||
|
|
||
| target_link_libraries(br-docs openbr ${BR_THIRDPARTY_LIBS} opencv_core) | ||
| install(TARGETS br-docs RUNTIME DESTINATION bin) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
|
|
||
| #include <QRegularExpression> | ||
| #include <stdio.h> | ||
|
|
||
| #include <openbr/openbr_plugin.h> | ||
|
|
||
| int main(int argc, char *argv[]) | ||
| { | ||
| QRegularExpression regex; | ||
|
|
||
| for (int i = 1; i < argc; i++) { | ||
| QString arg = QString::fromLocal8Bit(argv[i]); | ||
| if (arg == "--help" || arg == "-h") { | ||
| printf("Usage: br-docs\n"); | ||
| printf(" --regex <pattern> Only generate docs for transforms matching <pattern>\n"); | ||
| return 0; | ||
| } else if (arg == "--regex") { | ||
| regex = QRegularExpression(QString::fromLocal8Bit(argv[++i])); | ||
| } | ||
| } | ||
|
|
||
| br::Context::initialize(argc, argv); | ||
|
|
||
| br::AllDocs(regex); | ||
|
|
||
| br::Context::finalize(); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -210,6 +210,9 @@ class FakeMain : public QRunnable | |
| else if (!strcmp(fun, "help")) { | ||
| check(parc == 0, "No parameters expected for 'help'."); | ||
| help(); | ||
| } else if (!strcmp(fun, "docs")) { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. delete app/br-docs now? |
||
| check(parc == 0, "No parameters expected for 'docs'."); | ||
| br_docs(); | ||
| } else if (!strcmp(fun, "gui")) { | ||
| // Do nothing because we checked for this flag prior to initialization | ||
| } else if (!strcmp(fun, "objects")) { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -26,6 +26,8 @@ extern "C" { | |
|
|
||
| BR_EXPORT const char *br_about(); | ||
|
|
||
| BR_EXPORT void br_docs(); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would prefer to design this function like br_about() and return a string. The caller then has flexibility to choose between printf and other options. |
||
|
|
||
| BR_EXPORT void br_cat(int num_input_galleries, const char *input_galleries[], const char *output_gallery); | ||
|
|
||
| BR_EXPORT void br_deduplicate(const char *input_gallery, const char *output_gallery, const char *threshold); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -31,6 +31,7 @@ | |
| #include <QPoint> | ||
| #include <QPointF> | ||
| #include <QRectF> | ||
| #include <QRegularExpression> | ||
| #include <QScopedPointer> | ||
| #include <QSharedPointer> | ||
| #include <QString> | ||
|
|
@@ -752,6 +753,29 @@ class BR_EXPORT Transform : public Object | |
| virtual void train(const TemplateList &data); | ||
| virtual void train(const QList<TemplateList> &data); | ||
|
|
||
| void print_doc_header(QString doc, int indent) const { | ||
| QString name = this->file.suffix(); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Move the implementation of this non-trival function into openbr_plugin.cpp |
||
| QString params; | ||
| try { | ||
| params = Factory<Transform>::parameters("."+description(false)); | ||
| } catch (...) { | ||
| params = "???"; | ||
| } | ||
| printf("%*s%s(%s): %s\n", indent, "", name.toStdString().c_str(), params.toStdString().c_str(), doc.toStdString().c_str()); | ||
| } | ||
|
|
||
| void print_doc(QString doc, int indent) const { | ||
| printf("%*s%s\n", indent, "", doc.toStdString().c_str()); | ||
| } | ||
|
|
||
| virtual void docs(int indent) const { | ||
| print_doc_header(docs(), indent); | ||
| } | ||
|
|
||
| virtual const QString docs() const | ||
| { | ||
| return ""; | ||
| } | ||
|
|
||
| virtual void project(const Template &src, Template &dst) const = 0; | ||
| virtual void project(const TemplateList &src, TemplateList &dst) const; | ||
|
|
@@ -918,6 +942,10 @@ BR_EXPORT bool IsClassifier(const QString &algorithm); | |
|
|
||
| BR_EXPORT void Train(const File &input, const File &model); | ||
|
|
||
| BR_EXPORT void Docs(); | ||
|
|
||
| BR_EXPORT void AllDocs(QRegularExpression regex); | ||
|
|
||
| BR_EXPORT void Enroll(const File &input, const File &gallery = File()); | ||
|
|
||
| BR_EXPORT void Enroll(TemplateList &tmpl); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we need a separate CLI app here. I think
br -docsshould do this when-algorithmisn't set.