diff --git a/.gitignore b/.gitignore index 09d9bb958d57f57f3ba816c039dd26b336fc6bc2..f8b7e4b1614f1062626c13784354a39eb59cd50c 100644 --- a/.gitignore +++ b/.gitignore @@ -2,7 +2,7 @@ data bin obj/* obj/Makefile -!obj/recorder.pro +!obj/recorder*.pro .cache *.autosave diff --git a/README b/README index 5eaea057d9650b212c58dab1997726fa6285f2cf..f157c42a023711e68405e788e2ea5f5beb922788 100644 --- a/README +++ b/README @@ -6,3 +6,14 @@ Based of VimbaX SDK from: -> expanded on VimbaCPP/Example/AsyncOpenCVRecorder ! does: acquire images and store them as jpeg along with timestamps + +------------------------------- + +Software B actually consists of 2 apps: + + 1. recorder-cmd + a commandline app that is meant to be standalone and communicates with the camera + + 2. recorder-gui + a Qt GUI app, which calls the commandline app and displays the images + diff --git a/obj/recorder-cmd.pro b/obj/recorder-cmd.pro new file mode 100644 index 0000000000000000000000000000000000000000..47d1779e324a44cbb98e2a657eb42ae02c84e67c --- /dev/null +++ b/obj/recorder-cmd.pro @@ -0,0 +1,35 @@ +TEMPLATE = app + +QT += core +CONFIG += c++20 warn_on console + +SOURCES += \ + ../src/cmd/main.cpp \ + ../src/utils.cpp + +HEADERS += \ + ../src/utils.h + +DEFINES *= QT_USE_QSTRINGBUILDER #converts + to % when building strings + +# opencv +CONFIG += link_pkgconfig +PKGCONFIG += opencv4 + +# Vimba +INCLUDEPATH += ../vimbax/api/include +VIMBA_LIB_DIR = ../lib +LIBS += -L$${VIMBA_LIB_DIR} -lVmbC -lVmbCPP -Wl,-rpath,\'\$$ORIGIN\' + +#-Wl,-rpath,. +QMAKE_POST_LINK += cp $${VIMBA_LIB_DIR}/lib*.so ../bin # copy vmb-libs to bin + +#PRE_LINK: cp vimba libs once +# cp ../b/vimbax/api/lib/GenICam/*.so $${VIMBA_LIB_DIR} +# cp ../b/vimbax/api/lib/libVmb{C,CPP,ImageTransform}.so $${VIMBA_LIB_DIR} + +TARGET = recorder-cmd +DESTDIR = ../bin + +QMAKE_CLEAN += .cache/clangd/index/* .qmake.stash +#cant rm dir here, so added in project file diff --git a/obj/recorder.pro b/obj/recorder-gui.pro similarity index 91% rename from obj/recorder.pro rename to obj/recorder-gui.pro index 411c678af76f9ab6a72bcc958451bd39767d4587..d87299d0f8a65109572d46ac228e89c82b6bc2d5 100644 --- a/obj/recorder.pro +++ b/obj/recorder-gui.pro @@ -4,17 +4,17 @@ QT += core gui widgets CONFIG += c++20 warn_on SOURCES += \ - ../src/main.cpp \ - ../src/mainwindow.cpp \ + ../src/gui/main.cpp \ + ../src/gui/mainwindow.cpp \ ../src/utils.cpp HEADERS += \ ui_mainwindow.h \ - ../src/mainwindow.h \ + ../src/gui/mainwindow.h \ ../src/utils.h FORMS += \ - ../src/mainwindow.ui + ../src/gui/mainwindow.ui DEFINES *= QT_USE_QSTRINGBUILDER #converts + to % when building strings @@ -34,11 +34,11 @@ QMAKE_POST_LINK += cp $${VIMBA_LIB_DIR}/lib*.so ../bin # copy vmb-libs to bin # cp ../b/vimbax/api/lib/GenICam/*.so $${VIMBA_LIB_DIR} # cp ../b/vimbax/api/lib/libVmb{C,CPP,ImageTransform}.so $${VIMBA_LIB_DIR} -TARGET = recorder +TARGET = recorder-gui DESTDIR = ../bin QMAKE_CLEAN += .cache/clangd/index/* .qmake.stash -#cant rm dir here, so added in project file +#cant rm dir here, so added cmd in sublime project file diff --git a/recorder.sublime-project b/recorder.sublime-project index c5f34982e0620e068d5bdfe0712191c582cb8016..de7f6b1eb89a98ebb65cef08f31a5f97924c1cef 100644 --- a/recorder.sublime-project +++ b/recorder.sublime-project @@ -16,9 +16,11 @@ "build_systems": [ { - "name": "recorder", + "name": "recorder", // default is clean "working_dir": "$project_path/obj", - "shell_cmd": "qmake6 && make -j`nproc` && cd ../bin && recorder", + "shell_cmd": "make -j`nproc` clean && rmdir -p .cache/clangd/index", + + "env": {"run_args": "-o blubb/bla"}, // pass args to the program // COLORS in output - HOW?? // "env": {"GCC_COLORS": "error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01"}, //force color for some CLI programs @@ -39,38 +41,70 @@ "variants": [ { - "name": "rebuild && run", - "shell_cmd": "make -j`nproc` clean && qmake6 && make -j`nproc` -B && LD_LIBRARY_PATH=../bin", + "name": "gui: build & run", + "shell_cmd": "qmake6 recorder-gui.pro && make -j`nproc` && cd ../bin && recorder-gui", }, { - "name": "rebuild", - "shell_cmd": "make -j`nproc` clean && qmake6 && make -j`nproc` -B", + "name": "gui: run", + "shell_cmd": "cd ../bin && recorder-gui", }, { - "name": "build", - "shell_cmd": "qmake6 && make -j`nproc` ", + "name": "gui: build", + "shell_cmd": "qmake6 recorder-gui.pro && make -j`nproc` ", }, { - "name": "run", - "shell_cmd": "cd ../bin && recorder", + "name": "gui: rebuild", + "shell_cmd": "make -j`nproc` clean && qmake6 recorder-gui.pro && make -j`nproc` -B", }, { - "name": "qmake6", - "shell_cmd": "qmake6", + "name": "gui: rebuild && run", + "shell_cmd": "make -j`nproc` clean && qmake6 recorder-gui.pro && make -j`nproc` -B && LD_LIBRARY_PATH=../bin && recorder-gui", }, { - "name": "clean", - "shell_cmd": "make -j`nproc` clean && rmdir -p .cache/clangd/index", + "name": "gui: designer", + "shell_cmd": "designer ../src/gui/mainwindow.ui", }, { - "name": "bear -- create new compile_commands.json", - "shell_cmd": "bear -- make -j`nproc` && mv compile_commands.json ..", + "name": "-------------------------------", + "shell_cmd": "", + }, + { + "name": "cmd: build & run", + "shell_cmd": "qmake6 recorder-cmd.pro && make -j`nproc` && cd ../bin && recorder-cmd \\$run_args", + }, + { + "name": "cmd: run", + "shell_cmd": "cd ../bin && recorder-cmd \\$run_args", + }, + { + "name": "cmd: build", + "shell_cmd": "qmake6 recorder-cmd.pro && make -j`nproc` ", + }, + { + "name": "cmd: rebuild", + "shell_cmd": "make -j`nproc` clean && qmake6 recorder-cmd.pro && make -j`nproc` -B", }, { - "name": "designer", - "shell_cmd": "designer ../src/mainwindow.ui", + "name": "cmd: rebuild && run", + "shell_cmd": "make -j`nproc` clean && qmake6 recorder-cmd.pro && make -j`nproc` -B && LD_LIBRARY_PATH=../bin && recorder-cmd \\$run_args", + }, + { + "name": "-------------------------------", + "shell_cmd": "", + }, + { + "name": "bear -- create new compile_commands.json", + "shell_cmd": "bear -- make -j`nproc` && mv compile_commands.json ..", }, // { + // "name": "qmake6", + // "shell_cmd": "qmake6", + // }, + // { + // "name": "clean", + // "shell_cmd": "make -j`nproc` clean && rmdir -p .cache/clangd/index", + // }, + // { // "name": "distclean ", // "shell_cmd": "make -j`nproc` distclean", // }, @@ -80,5 +114,8 @@ ] } +// for more info see: +// https://www.sublimetext.com/docs/build_systems.html + //build sys @ ~/.config/sublime-text/Packages/User/C++.sublime-build diff --git a/src/cmd/main.cpp b/src/cmd/main.cpp new file mode 100644 index 0000000000000000000000000000000000000000..1a9fbf0a7282594c903a61419adda4cf84d4f8e5 --- /dev/null +++ b/src/cmd/main.cpp @@ -0,0 +1,100 @@ +#include "../utils.h" + +#include <iostream> + +#include <QCoreApplication> +#include <QCommandLineParser> +#include <QDir> + +using Qt::endl; +using namespace std; + +int main(int argc, char *argv[]) +{ + + QCoreApplication a(argc, argv); + QCoreApplication::setApplicationVersion(getVersionString()); + QCoreApplication::setApplicationName("recorder (cmd-line)"); + + QTextStream qout(stdout); //2d make global to access from anywhere + QTextStream qin(stdin); + qin.skipWhiteSpace(); // Remove white characters that interrupt + QTextStream qerr(stderr); + + // parse arguments + QCommandLineParser parser; + parser.setApplicationDescription("a commandline app that is meant to be standalone and communicates with the camera"); + parser.addHelpOption(); + parser.addVersionOption(); + parser.addOptions({ + {{"o", "out-dir"}, "store frames to <out-dir>", "out_dir"}, + {{"l", "list-cams"}, "list available cams"}, + {{"e", "export-cam-config"}, "export camera config" "settings.xml"}, + {{"i", "import-cam-config"}, "import camera config" "settings.xml"}, + {{"c", "calibrate"}, "calibrate cam"}, + {{"r", "record"}, "record"}, + {{"s", "stop"}, "stop recording"}, + // {{"f", "force"}, "Overwrite existing files."}, + // {{"n", "dry-run"}, "Do nothing. For testing purposes."}, + // {{"p", "progress"}, "Show progress during copy."}, + // {{"v", "verbose"}, "verbose"}, + }); + + parser.process(a); + + const QStringList args = parser.positionalArguments(); + // source is args.at(0), destination is args.at(1) + qDebug() << "args: " << args.join(", ") << "\n"; + + + qout << "Please enter your name: "; + qout.flush(); // clears the keyboard buffer + + QString inpu; + + // QString inpu = qin.readLine(); + qin >> inpu; + + qout << "u typed " << inpu.toLower() << endl; + + return 3; + + cout << "__LINE__" << __LINE__ << endl; //2d make snippet HERE for dbg + if( parser.isSet("o") ) + { + QDir out_dir(parser.value("o")); + if( !out_dir.exists() ) + { + qDebug() << "out_dir (" << out_dir.absolutePath() << ") doesn't exist. Should I Create it? [y|yes or other]\n"; + QString yn =""; + qin >> yn; + + QStringList yes{"y", "yes", "1", "ja", "j", "oui", "si"}; + if( yes.contains(yn.toLower()) ) + { + // out_dir.mkpath(out_dir.absolutePath()); + if( !out_dir.mkdir(".") ){ + cerr << "failed to create out_dir '" << out_dir.absolutePath().toStdString() << "'" << endl; + return 1; + } + } + else + { + cout << "u pressed no" << endl; + return 0; + } + } + + + + qDebug() << "out_dir: " << out_dir << "\n"; + } + // bool force = parser.isSet(forceOption); + // QString targetDir = parser.value(targetDirectoryOption); + + + + // return a.exec(); + return 0; +} + diff --git a/src/main.cpp b/src/gui/main.cpp similarity index 96% rename from src/main.cpp rename to src/gui/main.cpp index 69283e4a95d07de59a9fd86d651339839b47afbe..4d09e9dafa4ce6a82fc8ca63340a8ab8da3f0ced 100644 --- a/src/main.cpp +++ b/src/gui/main.cpp @@ -2,7 +2,7 @@ #include <QApplication> #include <QFile> -#include <QDir> +// #include <QDir> void loadStyleSheets(const QString& name, MainWindow& mw) @@ -21,6 +21,7 @@ void loadStyleSheets(const QString& name, MainWindow& mw) int main(int argc, char *argv[]) { + QApplication a(argc, argv); MainWindow w; loadStyleSheets(QCoreApplication::applicationDirPath()+"/style.qss", w); diff --git a/src/mainwindow.cpp b/src/gui/mainwindow.cpp similarity index 93% rename from src/mainwindow.cpp rename to src/gui/mainwindow.cpp index 28504dc440df4bc11a1016231d139348cd09e207..86a5014b80687dd594149661d8cd409373a36ba9 100644 --- a/src/mainwindow.cpp +++ b/src/gui/mainwindow.cpp @@ -33,11 +33,11 @@ MainWindow::MainWindow(QWidget *parent) { log( " Started Vimba C++ Api" ); updateCams(); - } - else - { - log( " Failed to start Vimba C++ Api" ); -} + } + else + { + log( " Failed to start Vimba C++ Api" ); + } } MainWindow::~MainWindow() @@ -45,11 +45,11 @@ MainWindow::~MainWindow() if ( VmbErrorSuccess == sys.Shutdown() ) { log( " Shutdown Vimba Api" ); - } - else - { - log( " Failed to Shutdown Vimba Api" ); - } + } + else + { + log( " Failed to Shutdown Vimba Api" ); + } delete ui; } @@ -159,8 +159,10 @@ void MainWindow::getCamInfo( const CameraPtr &camera ) //QTableWidgetItem(const QIcon &icon, const QString &text, int type = Type) addRow(infos); - QStringList sl= {randomString(),randomString(),randomString(),randomString(),randomString(),randomString()}; - addRow(sl); + + // random rows for mockup testing when no cam is avaiable + // QStringList sl= {randomString(),randomString(),randomString(),randomString(),randomString(),randomString()}; + // addRow(sl); } ///add row to listwidget diff --git a/src/mainwindow.h b/src/gui/mainwindow.h similarity index 100% rename from src/mainwindow.h rename to src/gui/mainwindow.h diff --git a/src/mainwindow.ui b/src/gui/mainwindow.ui similarity index 100% rename from src/mainwindow.ui rename to src/gui/mainwindow.ui diff --git a/src/recorder.cpp b/src/recorder.cpp index c8b89b2c216137d7eba562d0624bf01a442a2a9d..e60c56fd2f5ad81ef86ca5523360a59fbf400a4e 100644 --- a/src/recorder.cpp +++ b/src/recorder.cpp @@ -1,4 +1,4 @@ -#include "VmbCPP.h" +#include <VmbCPP/VmbCPP.h> #include <iostream> #include <vector> diff --git a/src/utils.cpp b/src/utils.cpp index d2b9bb39fda0acbbca6ca354ae003509c38f5636..890f1528adafeb6628d452d1f23abab1d4bd5b71 100644 --- a/src/utils.cpp +++ b/src/utils.cpp @@ -2,7 +2,7 @@ #include <random> -#include "mainwindow.h" +// #include "mainwindow.h" #include "VmbCPP/VmbCPP.h" #include <QString> #include <QDebug> @@ -10,7 +10,7 @@ const int APP_VERSION_MAJOR = 0; const int APP_VERSION_MINOR = 0; -const int APP_VERSION_PATCH = 4; +const int APP_VERSION_PATCH = 5; using namespace VmbCPP; @@ -19,7 +19,7 @@ const QString getVersionString() VmbVersionInfo_t version; VmbSystem::GetInstance().QueryVersion(version); - QString s = "### Versions\n"; + QString s = "\n### Versions\n"; s += QStringLiteral("# Recorder: %1.%2.%3\n").arg(APP_VERSION_MAJOR).arg(APP_VERSION_MINOR).arg(APP_VERSION_PATCH); s += QStringLiteral("# Vimba: %1.%2.%3\n").arg(version.major).arg(version.minor).arg(version.patch); s += QStringLiteral("# Qt: %1.%2.%3\n").arg(QT_VERSION_MAJOR).arg(QT_VERSION_MINOR).arg(QT_VERSION_PATCH);