Skip to content
Snippets Groups Projects
Commit d5c25742 authored by am0ebe's avatar am0ebe
Browse files

new architecture: 2 apps.

1. console app: recorder-cmd
2. gui app: recorder-gui

> set up build system for both apps
> console: read commandline arguments
> update gitignore
parent abdea612
No related branches found
No related tags found
No related merge requests found
...@@ -2,7 +2,7 @@ data ...@@ -2,7 +2,7 @@ data
bin bin
obj/* obj/*
obj/Makefile obj/Makefile
!obj/recorder.pro !obj/recorder*.pro
.cache .cache
*.autosave *.autosave
......
...@@ -6,3 +6,14 @@ Based of VimbaX SDK from: ...@@ -6,3 +6,14 @@ Based of VimbaX SDK from:
-> expanded on VimbaCPP/Example/AsyncOpenCVRecorder ! -> expanded on VimbaCPP/Example/AsyncOpenCVRecorder !
does: acquire images and store them as jpeg along with timestamps 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
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
...@@ -4,17 +4,17 @@ QT += core gui widgets ...@@ -4,17 +4,17 @@ QT += core gui widgets
CONFIG += c++20 warn_on CONFIG += c++20 warn_on
SOURCES += \ SOURCES += \
../src/main.cpp \ ../src/gui/main.cpp \
../src/mainwindow.cpp \ ../src/gui/mainwindow.cpp \
../src/utils.cpp ../src/utils.cpp
HEADERS += \ HEADERS += \
ui_mainwindow.h \ ui_mainwindow.h \
../src/mainwindow.h \ ../src/gui/mainwindow.h \
../src/utils.h ../src/utils.h
FORMS += \ FORMS += \
../src/mainwindow.ui ../src/gui/mainwindow.ui
DEFINES *= QT_USE_QSTRINGBUILDER #converts + to % when building strings 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 ...@@ -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/GenICam/*.so $${VIMBA_LIB_DIR}
# cp ../b/vimbax/api/lib/libVmb{C,CPP,ImageTransform}.so $${VIMBA_LIB_DIR} # cp ../b/vimbax/api/lib/libVmb{C,CPP,ImageTransform}.so $${VIMBA_LIB_DIR}
TARGET = recorder TARGET = recorder-gui
DESTDIR = ../bin DESTDIR = ../bin
QMAKE_CLEAN += .cache/clangd/index/* .qmake.stash 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
......
...@@ -16,9 +16,11 @@ ...@@ -16,9 +16,11 @@
"build_systems": "build_systems":
[ [
{ {
"name": "recorder", "name": "recorder", // default is clean
"working_dir": "$project_path/obj", "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?? // 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 // "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 @@ ...@@ -39,38 +41,70 @@
"variants": "variants":
[ [
{ {
"name": "rebuild && run", "name": "gui: build & run",
"shell_cmd": "make -j`nproc` clean && qmake6 && make -j`nproc` -B && LD_LIBRARY_PATH=../bin", "shell_cmd": "qmake6 recorder-gui.pro && make -j`nproc` && cd ../bin && recorder-gui",
}, },
{ {
"name": "rebuild", "name": "gui: run",
"shell_cmd": "make -j`nproc` clean && qmake6 && make -j`nproc` -B", "shell_cmd": "cd ../bin && recorder-gui",
}, },
{ {
"name": "build", "name": "gui: build",
"shell_cmd": "qmake6 && make -j`nproc` ", "shell_cmd": "qmake6 recorder-gui.pro && make -j`nproc` ",
}, },
{ {
"name": "run", "name": "gui: rebuild",
"shell_cmd": "cd ../bin && recorder", "shell_cmd": "make -j`nproc` clean && qmake6 recorder-gui.pro && make -j`nproc` -B",
}, },
{ {
"name": "qmake6", "name": "gui: rebuild && run",
"shell_cmd": "qmake6", "shell_cmd": "make -j`nproc` clean && qmake6 recorder-gui.pro && make -j`nproc` -B && LD_LIBRARY_PATH=../bin && recorder-gui",
}, },
{ {
"name": "clean", "name": "gui: designer",
"shell_cmd": "make -j`nproc` clean && rmdir -p .cache/clangd/index", "shell_cmd": "designer ../src/gui/mainwindow.ui",
}, },
{ {
"name": "bear -- create new compile_commands.json", "name": "-------------------------------",
"shell_cmd": "bear -- make -j`nproc` && mv compile_commands.json ..", "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", "name": "cmd: rebuild && run",
"shell_cmd": "designer ../src/mainwindow.ui", "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 ", // "name": "distclean ",
// "shell_cmd": "make -j`nproc` distclean", // "shell_cmd": "make -j`nproc` distclean",
// }, // },
...@@ -80,5 +114,8 @@ ...@@ -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 //build sys @ ~/.config/sublime-text/Packages/User/C++.sublime-build
#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;
}
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
#include <QApplication> #include <QApplication>
#include <QFile> #include <QFile>
#include <QDir> // #include <QDir>
void loadStyleSheets(const QString& name, MainWindow& mw) void loadStyleSheets(const QString& name, MainWindow& mw)
...@@ -21,6 +21,7 @@ void loadStyleSheets(const QString& name, MainWindow& mw) ...@@ -21,6 +21,7 @@ void loadStyleSheets(const QString& name, MainWindow& mw)
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
QApplication a(argc, argv); QApplication a(argc, argv);
MainWindow w; MainWindow w;
loadStyleSheets(QCoreApplication::applicationDirPath()+"/style.qss", w); loadStyleSheets(QCoreApplication::applicationDirPath()+"/style.qss", w);
......
...@@ -33,11 +33,11 @@ MainWindow::MainWindow(QWidget *parent) ...@@ -33,11 +33,11 @@ MainWindow::MainWindow(QWidget *parent)
{ {
log( " Started Vimba C++ Api" ); log( " Started Vimba C++ Api" );
updateCams(); updateCams();
} }
else else
{ {
log( " Failed to start Vimba C++ Api" ); log( " Failed to start Vimba C++ Api" );
} }
} }
MainWindow::~MainWindow() MainWindow::~MainWindow()
...@@ -45,11 +45,11 @@ MainWindow::~MainWindow() ...@@ -45,11 +45,11 @@ MainWindow::~MainWindow()
if ( VmbErrorSuccess == sys.Shutdown() ) if ( VmbErrorSuccess == sys.Shutdown() )
{ {
log( " Shutdown Vimba Api" ); log( " Shutdown Vimba Api" );
} }
else else
{ {
log( " Failed to Shutdown Vimba Api" ); log( " Failed to Shutdown Vimba Api" );
} }
delete ui; delete ui;
} }
...@@ -159,8 +159,10 @@ void MainWindow::getCamInfo( const CameraPtr &camera ) ...@@ -159,8 +159,10 @@ void MainWindow::getCamInfo( const CameraPtr &camera )
//QTableWidgetItem(const QIcon &icon, const QString &text, int type = Type) //QTableWidgetItem(const QIcon &icon, const QString &text, int type = Type)
addRow(infos); 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 ///add row to listwidget
......
File moved
File moved
#include "VmbCPP.h" #include <VmbCPP/VmbCPP.h>
#include <iostream> #include <iostream>
#include <vector> #include <vector>
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
#include <random> #include <random>
#include "mainwindow.h" // #include "mainwindow.h"
#include "VmbCPP/VmbCPP.h" #include "VmbCPP/VmbCPP.h"
#include <QString> #include <QString>
#include <QDebug> #include <QDebug>
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
const int APP_VERSION_MAJOR = 0; const int APP_VERSION_MAJOR = 0;
const int APP_VERSION_MINOR = 0; const int APP_VERSION_MINOR = 0;
const int APP_VERSION_PATCH = 4; const int APP_VERSION_PATCH = 5;
using namespace VmbCPP; using namespace VmbCPP;
...@@ -19,7 +19,7 @@ const QString getVersionString() ...@@ -19,7 +19,7 @@ const QString getVersionString()
VmbVersionInfo_t version; VmbVersionInfo_t version;
VmbSystem::GetInstance().QueryVersion(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("# 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("# 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); s += QStringLiteral("# Qt: %1.%2.%3\n").arg(QT_VERSION_MAJOR).arg(QT_VERSION_MINOR).arg(QT_VERSION_PATCH);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment