Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision

Target

Select target project
  • sugu/vimba
1 result
Select Git revision
Show changes
Commits on Source (3)
......@@ -2,8 +2,10 @@ data
bin
obj/*
obj/Makefile
!obj/recorder.pro
!obj/recorder*.pro
.cache
*.autosave
*.o
*.avi
*.sublime-workspace
......
......@@ -5,4 +5,15 @@ Based of VimbaX SDK from:
-> expanded on VimbaCPP/Example/AsyncOpenCVRecorder !
used to 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/cmd/console.cpp \
../src/cmd/core.cpp \
../src/utils.cpp
HEADERS += \
../src/cmd/console.h \
../src/cmd/core.h \
../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
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
......
......@@ -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,34 +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": "gui: run",
"shell_cmd": "cd ../bin && recorder-gui",
},
{
"name": "gui: build",
"shell_cmd": "qmake6 recorder-gui.pro && make -j`nproc` ",
},
{
"name": "gui: rebuild",
"shell_cmd": "make -j`nproc` clean && qmake6 recorder-gui.pro && make -j`nproc` -B",
},
{
"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": "gui: designer",
"shell_cmd": "designer ../src/gui/mainwindow.ui",
},
{
"name": "-------------------------------",
"shell_cmd": "",
},
{
"name": "cmd: build & run",
"shell_cmd": "qmake6 recorder-cmd.pro && make -j`nproc` && cd ../bin && recorder-cmd \\$run_args",
},
{
"name": "rebuild",
"shell_cmd": "make -j`nproc` clean && qmake6 && make -j`nproc` -B",
"name": "cmd: run",
"shell_cmd": "cd ../bin && recorder-cmd \\$run_args",
},
{
"name": "build",
"shell_cmd": "qmake6 && make -j`nproc` ",
"name": "cmd: build",
"shell_cmd": "qmake6 recorder-cmd.pro && make -j`nproc` ",
},
{
"name": "run",
"shell_cmd": "cd ../bin && recorder",
"name": "cmd: rebuild",
"shell_cmd": "make -j`nproc` clean && qmake6 recorder-cmd.pro && make -j`nproc` -B",
},
{
"name": "qmake6",
"shell_cmd": "qmake6",
"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": "clean",
"shell_cmd": "make -j`nproc` clean && rmdir -p .cache/clangd/index",
"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",
// },
......@@ -76,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
#include "console.h"
#include "qcoreapplication.h"
#include <QDebug>
#include <QCoreApplication>
#include <iostream>
#include <math.h>
void Console::listenKeys()
{
// listen to keyevents in endless loop
/* This is an expensive or blocking operation, why we use threaded approach to not block main event loop! */
std::string line;
forever
{
std::getline(std::cin, line);
emit keyPressed(line[0]);
if( line[0] == 'q' )
break;
}
}
void Console::updateCam(const QStringList& camInfo )
{
qDebug() << camInfo;
}
Controller::Controller()
{
Console *console = new Console;
console->moveToThread(&thread);
connect(&thread, &QThread::finished, console, &QObject::deleteLater);
connect(this, &Controller::operate, console, &Console::listenKeys);
connect(console, &Console::keyPressed, this, &Controller::keyPress);
thread.start();
}
Controller::~Controller()
{
thread.quit();
thread.wait(); //wait for thread to finish
// qDebug() << __FUNCTION__ << "():" << __LINE__ << ": ";
}
void Controller::keyPress(const QChar& key)
{
qDebug() << __FUNCTION__ << "u pressed " << key;
switch (key.unicode())
{
case 'l':
emit listCams();
break;
case 'q':
qApp->quit();
break;
}
}
#pragma once
#include <QObject>
#include <QThread>
// derived from qthread example
// https://doc.qt.io/qt-6/qthread.html
class Console : public QObject
{
Q_OBJECT
public slots:
void updateCam(const QStringList &);
void listenKeys();
signals:
void keyPressed(const QChar &key);
};
class Controller : public QObject
{
Q_OBJECT
QThread thread;
public:
Controller();
~Controller();
public slots:
void keyPress(const QChar &);
signals:
void operate();
void listCams();
void printVersion();
// ... more signals here
};
#include "core.h"
#include "../utils.h"
#include <iostream>
#include <vector>
#include <VmbCPP/VmbCPP.h>
// #include "qglobal.h"
#include <QDebug>
using namespace VmbCPP;
Core::Core() :
apiStarted( false ),
sys( VmbSystem::GetInstance() ), // Create and get Vimba singleton
cameras( CameraPtrVector() ), // Holds camera handles
camIdx(0)
{
if ( VmbErrorSuccess == sys.Startup() )
{
apiStarted = true;
qDebug() << "init API :)";
}
else
{
qDebug() << "Couldn't initialize API";
}
initCams();
}
void Core::initCams()
{
if ( VmbErrorSuccess == sys.GetCameras( cameras ) )
{
qDebug() << "found " << cameras.size() << " cameras";
}
else
{
qDebug() << "Couldn't get cameras";
}
}
Core::~Core()
{
// close each camera in cameras
for ( auto iter = cameras.begin (); cameras.end () != iter; ++ iter )
(*iter)->Close();
qDebug() << __FUNCTION__ << "():" << __LINE__;
sys.Shutdown(); //unload TL's
}
CameraPtr Core::cam()
{
return cameras.at(camIdx);
}
void Core::setCam(ulong idx)
{
if( idx >= cameras.size() )
idx = cameras.size() - 1;
camIdx = idx;
}
void Core::listCams()
{
qDebug() << __FUNCTION__ << "():" << __LINE__;
if( !apiStarted )
return;
// id,name,model,serial,interfaceID
std::for_each( cameras.begin(), cameras.end(), [this](const CameraPtr & camera)
{
std::string str;
QStringList camInfo;
VmbErrorType err = camera->GetID( str );
if( VmbErrorSuccess != err )
str = errorCodeToMessage(err).toStdString();
camInfo << QString::fromStdString(str);
err = camera->GetName( str );
if( VmbErrorSuccess != err )
str = errorCodeToMessage(err).toStdString();
camInfo << QString::fromStdString(str);
err = camera->GetModel( str );
if( VmbErrorSuccess != err )
str = errorCodeToMessage(err).toStdString();
camInfo << QString::fromStdString(str);
err = camera->GetSerialNumber( str );
if( VmbErrorSuccess != err )
str = errorCodeToMessage(err).toStdString();
camInfo << QString::fromStdString(str);
err = camera->GetInterfaceID( str );
if( VmbErrorSuccess != err )
str = errorCodeToMessage(err).toStdString();
camInfo << QString::fromStdString(str);
camInfo << "closed"; //initially cams are closed, right?
qDebug() << camInfo;
emit camsDetected(camInfo);
} );
}
#pragma once
#include "qglobal.h"
#include <QObject>
#include <VmbCPP/Interface.h>
namespace VmbCPP {
class VmbSystem;
}
using VmbCPP::CameraPtr;
class Core : public QObject
{
Q_OBJECT
public:
Core();
~Core();
public slots:
void listCams();
signals:
void camsDetected(const QStringList &);
private:
void initCams();
static void getCamInfo( const CameraPtr & );
CameraPtr cam();
void setCam(ulong idx);
bool apiStarted;
VmbCPP::VmbSystem& sys;
VmbCPP::CameraPtrVector cameras;
ulong camIdx;
};
#include "../utils.h"
#include "console.h"
#include "core.h"
#include <iostream>
#include <QCoreApplication>
#include <QCommandLineParser>
#include <QDir>
#include <QTimer>
using namespace std; //string/cin/cerr/cout/endl
bool maybeCreateDir(QDir out_dir)
{
if( !out_dir.exists() )
{
qDebug() << "out_dir (" << out_dir.absolutePath() << ") doesn't exist. Should I Create it? ['y'-yes, '?'-no]\n";
char c='y';
cin >> c;
if( c == 'y' )
{
cout << "u pressed yes" << endl;
if( out_dir.mkpath(out_dir.absolutePath())) {
cout << "created out_dir" << endl;
}
else
{
cerr << "failed to create out_dir '" << out_dir.absolutePath().toStdString() << "'" << endl;
return false;
}
}
else
{
cout << "u pressed no" << endl;
return false;
}
}
qDebug() << "out_dir: " << out_dir.dirName() << "\n";
return true;
}
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
QCoreApplication::setApplicationVersion(getVersionString());
QCoreApplication::setApplicationName("recorder");
Controller controller;
QTimer::singleShot(0, &controller, SIGNAL(operate()));
Core core;
QObject::connect(&controller, &Controller::listCams, &core, &Core::listCams);
QObject::connect(&core, &Core::camsDetected, &console, &Console::updateCam);
// for testing:
QTimer::singleShot(0, &core, SLOT(listCams()));
return a.exec();
}
// // 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", "start record"}, "record"},
// {{"s", "stop record"}, "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";
// if( parser.isSet("o") )
// {
// maybeCreateDir(parser.value("o"));
// }
......@@ -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);
......
#include "utils.h"
#include "mainwindow.h"
#include "../obj/ui_mainwindow.h"
#include <QDebug>
#include <QKeyEvent>
#include <unistd.h>
#include <iostream>
using namespace VmbCPP;
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
, ui(new Ui::MainWindow)
, sys(VmbSystem::GetInstance()) // Create and get Vimba singleton
, curCam(CameraPtr())
, cameras(CameraPtrVector())
, camInfoNames({"name","model","id","serial","interface","state"})
{
ui->setupUi(this);
ui->tw_cams->setColumnCount(camInfoNames.size());
ui->tw_cams->setHorizontalHeaderLabels(camInfoNames);
QObject::connect(ui->b_update, SIGNAL(clicked()), this, SLOT(updateCams()));
QObject::connect(ui->b_openclose, SIGNAL(clicked()), this, SLOT(openCloseCam()));
QObject::connect(ui->tw_cams, SIGNAL(cellClicked(int,int)), this, SLOT(selectCam(int,int)));
log(getVersionString());
if ( VmbErrorSuccess == sys.Startup() )
{
log( " Started Vimba C++ Api" );
updateCams();
}
else
{
log( " Failed to start Vimba C++ Api" );
}
}
MainWindow::~MainWindow()
{
if ( VmbErrorSuccess == sys.Shutdown() )
{
log( " Shutdown Vimba Api" );
}
else
{
log( " Failed to Shutdown Vimba Api" );
}
delete ui;
}
void MainWindow::keyPressEvent(QKeyEvent *e)
{
//will not work on other windows (eg floating dockwidgets)
if ( e->key() == Qt::Key_Escape )
{
qApp->quit();
}
return QWidget::keyPressEvent(e);
}
void MainWindow::selectCam(int row,int )
{
curCam = cameras.at(row);
//display Stream on label (stackedWidget)
//display options in dockwidget-right
}
void MainWindow::openCloseCam()
{
QPushButton* b = ui->b_openclose;
if( b->text() == "open" )
{
auto ret = curCam->Open(VmbAccessModeFull);
// log( QString("foo"));
if( ret == VmbErrorSuccess )
b->setText("close");
log( QString("Open camera"), ret );
}
else if( b->text() == "close" )
{
auto ret = curCam->Close();
if( ret == VmbErrorSuccess )
b->setText("open");
log( QString("Close camera"), ret );
}
}
void MainWindow::updateCams()
{
// clear
ui->tw_cams->setRowCount(0);
ui->tw_cams->clearContents(); //dont remove headers
curCam = CameraPtr();
cameras = CameraPtrVector();
// get new
VmbErrorType err = sys.GetCameras( cameras ); // fetch all cameras known to Vimba
if( VmbErrorSuccess == err )
{
// query and print all _static_ details of all known cams [without opening cams]
// auto ncam = cameras.size();
// log( QString("Found %1 Camera%2!").arg(ncam).arg(ncam>1?"s":""));
if( cameras.size() )
ui->tw_cams->setCurrentCell(0,0); //select row
}
else
{
log( QString("Could not list cameras."), err);
}
}
/// get static cam info
void MainWindow::getCamInfo( const CameraPtr &camera )
{
std::string str;
QStringList infos;
infos << "closed"; //initially cams are closed, right?
addRow(infos);
}
///add row to listwidget
void MainWindow::addRow( QStringList& camInfos )
{
auto row = ui->tw_cams->rowCount();
ui->tw_cams->setRowCount(row+1);
for( auto col=0; col < ui->tw_cams->columnCount(); col++)
{
auto item = new QTableWidgetItem( camInfos.at(col) );
item->setTextAlignment(Qt::AlignCenter);
item->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable); //but not editable!
ui->tw_cams->setItem( row, col, item );
}
}
void MainWindow::log(QString msg, VmbError_t err )
{
msg.append(QString("%1").arg(errorCodeToMessage(err)));
//for std::string, use: log(QString::fromStdString(msg))
auto idx = ui->lw_log->count()-1;
ui->lw_log->insertItem( idx , msg );
qDebug() << msg;
}
//XXX use sth like isClosed() instead??
//XXX use icon instead of text
//QTableWidgetItem(const QIcon &icon, const QString &text, int type = Type)
// addRow(infos);
// random rows for mockup testing when no cam is avaiable
// QStringList sl= {randomString(),randomString(),randomString(),randomString(),randomString(),randomString()};
// addRow(sl);
......@@ -11,32 +11,32 @@ QT_END_NAMESPACE
class MainWindow : public QMainWindow
{
Q_OBJECT
Q_OBJECT
public:
MainWindow(QWidget *parent = nullptr);
~MainWindow();
MainWindow(QWidget *parent = nullptr);
~MainWindow();
public slots:
void log(QString,VmbError_t err = VmbErrorJustInfo);
void log(QString,VmbError_t err = VmbErrorJustInfo);
private slots:
void updateCams();
void openCloseCam();
void selectCam(int,int);
void updateCams();
void openCloseCam();
void selectCam(int,int);
protected:
void keyPressEvent(QKeyEvent *);
void keyPressEvent(QKeyEvent *);
private:
void getCamInfo( const VmbCPP::CameraPtr &camera );
void addRow( QStringList& );
void getCamInfo( const VmbCPP::CameraPtr &camera );
void addRow( QStringList& );
Ui::MainWindow *ui;
VmbCPP::VmbSystem &sys;
Ui::MainWindow *ui;
VmbCPP::VmbSystem &sys;
VmbCPP::CameraPtr curCam;
VmbCPP::CameraPtrVector cameras;
QStringList camInfoNames;
VmbCPP::CameraPtr curCam;
VmbCPP::CameraPtrVector cameras;
QStringList camInfoNames;
};
#endif // MAINWINDOW_H
File moved
#include "utils.h"
#include "mainwindow.h"
#include "../obj/ui_mainwindow.h"
#include <QDebug>
#include <QKeyEvent>
#include <unistd.h>
#include <iostream>
using namespace VmbCPP;
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
, ui(new Ui::MainWindow)
, sys(VmbSystem::GetInstance()) // Create and get Vimba singleton
, curCam(CameraPtr())
, cameras(CameraPtrVector())
, camInfoNames({"name","model","id","serial","interface","state"})
{
ui->setupUi(this);
ui->tw_cams->setColumnCount(camInfoNames.size());
ui->tw_cams->setHorizontalHeaderLabels(camInfoNames);
QObject::connect(ui->b_update, SIGNAL(clicked()), this, SLOT(updateCams()));
QObject::connect(ui->b_openclose, SIGNAL(clicked()), this, SLOT(openCloseCam()));
QObject::connect(ui->tw_cams, SIGNAL(cellClicked(int,int)), this, SLOT(selectCam(int,int)));
log(getVersionString());
if ( VmbErrorSuccess == sys.Startup() )
{
log( " Started Vimba C++ Api" );
updateCams();
}
else
{
log( " Failed to start Vimba C++ Api" );
}
}
MainWindow::~MainWindow()
{
if ( VmbErrorSuccess == sys.Shutdown() )
{
log( " Shutdown Vimba Api" );
}
else
{
log( " Failed to Shutdown Vimba Api" );
}
delete ui;
}
void MainWindow::keyPressEvent(QKeyEvent *e)
{
//will not work on other windows (eg floating dockwidgets)
if ( e->key() == Qt::Key_Escape )
{
qApp->quit();
}
return QWidget::keyPressEvent(e);
}
void MainWindow::selectCam(int row,int )
{
curCam = cameras.at(row);
//display Stream on label (stackedWidget)
//display options in dockwidget-right
}
void MainWindow::openCloseCam()
{
QPushButton* b = ui->b_openclose;
if( b->text() == "open" )
{
auto ret = curCam->Open(VmbAccessModeFull);
// log( QString("foo"));
if( ret == VmbErrorSuccess )
b->setText("close");
log( QString("Open camera"), ret );
}
else if( b->text() == "close" )
{
auto ret = curCam->Close();
if( ret == VmbErrorSuccess )
b->setText("open");
log( QString("Close camera"), ret );
}
}
void MainWindow::updateCams()
{
// clear
ui->tw_cams->setRowCount(0);
ui->tw_cams->clearContents(); //dont remove headers
curCam = CameraPtr();
cameras = CameraPtrVector();
// get new
VmbErrorType err = sys.GetCameras( cameras ); // fetch all cameras known to Vimba
if( VmbErrorSuccess == err )
{
// query and print all _static_ details of all known cams [without opening cams]
auto ncam = cameras.size();
log( QString("Found %1 Camera%2!").arg(ncam).arg(ncam>1?"s":""));
auto mf = std::bind(&MainWindow::getCamInfo, this, std::placeholders::_1); //weird syntax for calling non-static memberfunction in for_each...
// ui->tw_cams->setRowCount(ncam);
std::for_each( cameras.begin(), cameras.end(), mf );
if( cameras.size() )
ui->tw_cams->setCurrentCell(0,0); //select row
}
else
{
log( QString("Could not list cameras."), err);
}
}
/// get static cam info
void MainWindow::getCamInfo( const CameraPtr &camera )
{
std::string str;
QStringList infos;
VmbErrorType err = camera->GetID( str );
if( VmbErrorSuccess != err )
str = errorCodeToMessage(err).toStdString();
infos << QString::fromStdString(str);
err = camera->GetName( str );
if( VmbErrorSuccess != err )
str = errorCodeToMessage(err).toStdString();
infos << QString::fromStdString(str);
err = camera->GetModel( str );
if( VmbErrorSuccess != err )
str = errorCodeToMessage(err).toStdString();
infos << QString::fromStdString(str);
err = camera->GetSerialNumber( str );
if( VmbErrorSuccess != err )
str = errorCodeToMessage(err).toStdString();
infos << QString::fromStdString(str);
err = camera->GetInterfaceID( str );
if( VmbErrorSuccess != err )
str = errorCodeToMessage(err).toStdString();
infos << QString::fromStdString(str);
infos << "closed"; //initially cams are closed, right?
//XXX use sth like isClosed() instead??
//XXX use icon instead of text
//QTableWidgetItem(const QIcon &icon, const QString &text, int type = Type)
addRow(infos);
QStringList sl= {randomString(),randomString(),randomString(),randomString(),randomString(),randomString()};
addRow(sl);
}
///add row to listwidget
void MainWindow::addRow( QStringList& camInfos )
{
auto row = ui->tw_cams->rowCount();
ui->tw_cams->setRowCount(row+1);
for( auto col=0; col < ui->tw_cams->columnCount(); col++)
{
auto item = new QTableWidgetItem( camInfos.at(col) );
item->setTextAlignment(Qt::AlignCenter);
item->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable); //but not editable!
ui->tw_cams->setItem( row, col, item );
}
}
void MainWindow::log(QString msg, VmbError_t err )
{
msg.append(QString("%1").arg(errorCodeToMessage(err)));
//for std::string, use: log(QString::fromStdString(msg))
auto idx = ui->lw_log->count()-1;
ui->lw_log->insertItem( idx , msg );
qDebug() << msg;
}
#include "VmbCPP.h"
#include <VmbCPP/VmbCPP.h>
#include <iostream>
#include <vector>
......@@ -11,9 +11,8 @@
using std::cout;
using std::endl;
// using namespace VmbCPP;
// using namespace VmbCPP;
// read_and_display_img("/home/sugu/code/c++/opencv_quark/starry_night.png"); //make HOME user independent
// int read_and_display_img( cv::String img_with_path )
......@@ -35,51 +34,4 @@ using std::endl;
// }
// int main(int argc, char const *argv[])
// {
// CameraPtrVector cameras;
// if ( VmbErrorSuccess == sys.Startup() )
// {
// sys.GetCameras( cameras );
// if ( VmbErrorSuccess == sys.GetCameras ( cameras ) )
// {
// cout << "found " << cameras.size() << " cameras" << endl;
// for ( auto iter = cameras.begin (); cameras.end () != iter; ++ iter )
// {
// if ( VmbErrorSuccess == (* iter)->Open( VmbAccessModeFull ) )
// {
// std::cout << " Camera opened " << std::endl;
// std::string str;
// (*iter)->GetID( str );
// std::cout << " Id: " << str << std::endl;
// (*iter)->GetName( str );
// std::cout << " name: " << str << std::endl;
// (*iter)->GetModel( str );
// std::cout << " model: " << str << std::endl;
// (*iter)->GetSerialNumber( str );
// std::cout << " serial: " << str << std::endl;
// // (*iter)->GetPermittedAccess( VmbAccessModeType& );
// // std::cout << " model: " << str << std::endl;
// (*iter)->GetInterfaceID( str ); //name/id of connected IF
// std::cout << " interfaceID: " << str << std::endl;
// }
// }
// }
// else
// {
// cout << "Couldn't get cameras" << endl;
// }
// sys.Shutdown(); //unload TLs
// }
// else
// {
// cout << "Couldn't initialize API" << endl;
// }
// return 0;
// }
// // }}
......@@ -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);
......