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
  • cali
  • dev
  • master
3 results

Target

Select target project
  • sugu/vimba
1 result
Select Git revision
  • cali
  • dev
  • master
3 results
Show changes
Commits on Source (5)
......@@ -7,11 +7,15 @@ SOURCES += \
../src/cmd/main.cpp \
../src/cmd/console.cpp \
../src/cmd/core.cpp \
../src/cmd/frameObserver.cpp \
../src/cmd/frameProcessor.cpp \
../src/utils.cpp
HEADERS += \
../src/cmd/console.h \
../src/cmd/core.h \
../src/cmd/frameObserver.h \
../src/cmd/frameProcessor.h \
../src/utils.h
DEFINES *= QT_USE_QSTRINGBUILDER #converts + to % when building strings
......@@ -27,12 +31,13 @@ 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
QMAKE_CXXFLAGS += -Wno-deprecated-enum-enum-conversion # ignore opencv warnings.
#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
TARGET = cmd
DESTDIR = ../bin
QMAKE_CLEAN += .cache/clangd/index/* .qmake.stash
......
......@@ -41,52 +41,52 @@
"variants":
[
{
"name": "gui: build & run",
"shell_cmd": "qmake6 recorder-gui.pro && make -j`nproc` && cd ../bin && recorder-gui",
"name": "cmd: build & run",
"shell_cmd": "qmake6 recorder-cmd.pro && make -j`nproc` && cd ../bin && recorder-cmd \\$run_args",
},
{
"name": "gui: run",
"shell_cmd": "cd ../bin && recorder-gui",
"name": "cmd: run",
"shell_cmd": "cd ../bin && recorder-cmd \\$run_args",
},
{
"name": "gui: build",
"shell_cmd": "qmake6 recorder-gui.pro && make -j`nproc` ",
"name": "cmd: build",
"shell_cmd": "qmake6 recorder-cmd.pro && make -j`nproc` ",
},
{
"name": "gui: rebuild",
"shell_cmd": "make -j`nproc` clean && qmake6 recorder-gui.pro && make -j`nproc` -B",
"name": "cmd: rebuild",
"shell_cmd": "make -j`nproc` clean && qmake6 recorder-cmd.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": "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": "gui: designer",
"shell_cmd": "designer ../src/gui/mainwindow.ui",
"name": "gui: build & run",
"shell_cmd": "qmake6 recorder-gui.pro && make -j`nproc` && cd ../bin && recorder-gui",
},
{
"name": "-------------------------------",
"shell_cmd": "",
},
{
"name": "cmd: build & run",
"shell_cmd": "qmake6 recorder-cmd.pro && make -j`nproc` && cd ../bin && recorder-cmd \\$run_args",
"name": "gui: run",
"shell_cmd": "cd ../bin && recorder-gui",
},
{
"name": "cmd: run",
"shell_cmd": "cd ../bin && recorder-cmd \\$run_args",
"name": "gui: build",
"shell_cmd": "qmake6 recorder-gui.pro && make -j`nproc` ",
},
{
"name": "cmd: build",
"shell_cmd": "qmake6 recorder-cmd.pro && make -j`nproc` ",
"name": "gui: rebuild",
"shell_cmd": "make -j`nproc` clean && qmake6 recorder-gui.pro && make -j`nproc` -B",
},
{
"name": "cmd: rebuild",
"shell_cmd": "make -j`nproc` clean && qmake6 recorder-cmd.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": "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": "gui: designer",
"shell_cmd": "designer ../src/gui/mainwindow.ui",
},
{
"name": "-------------------------------",
......@@ -96,6 +96,8 @@
"name": "bear -- create new compile_commands.json",
"shell_cmd": "bear -- make -j`nproc` && mv compile_commands.json ..",
},
// {
// "name": "qmake6",
// "shell_cmd": "qmake6",
......
......@@ -23,30 +23,47 @@ void Console::listenKeys()
}
}
void Console::error(const int& errCode )
{
if( errCode )
{
QString errStr=errorCodeToMessage( errCode );
qDebug().noquote() << errStr;
}
}
void Console::error(const QString& str, const int& errCode=0 )
{
if( str != "" )
qDebug().noquote() << "⚠️ " << str;
error(errCode);
}
void Console::print(const QString& str )
{
qDebug() << str;
qDebug().noquote() << str;
}
void Console::printList(QStringList& list )
void Console::printList(const QStringList& list )
{
for ( auto& str : list )
for ( auto str : list )
{
str.replace(DELIM," ");
qDebug() << str << " ";
qDebug().noquote() << str << " ";
}
}
Controller::Controller()
// ###############################
// Controller
Controller::Controller() : console(new Console())
{
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);
connect(this, &Controller::print, console, &Console::print, Qt::DirectConnection); //just delegate to console
connect(this, &Controller::printList, console, &Console::printList, Qt::DirectConnection); //just delegate to console
thread.start();
}
......@@ -54,33 +71,43 @@ Controller::~Controller()
{
thread.quit();
thread.wait(); //wait for thread to finish
// qDebug() << __FUNCTION__ << "():" << __LINE__ << ": ";
// qDebug().noquote() << __FUNCTION__ << "():" << __LINE__ << ": ";
}
void Controller::keyPress(const QChar& key)
{
qDebug() << __FUNCTION__ << ": " << key;
qDebug().noquote() << __FUNCTION__ << ": " << key;
if ( key.isDigit() )
{
emit selectCam(key.digitValue());
emit selectCam(key.digitValue()-1);
}
else
{
switch (key.unicode())
{
// XXX add new func
case 'h':
emit printHelp();
break;
case 'o':
emit openCam();
break;
case 'l':
emit listCams();
break;
case 'r':
emit record();
break;
case 'v':
emit printVersion();
break;
case 'q':
qApp->quit();
break;
......
......@@ -12,8 +12,10 @@ class Console : public QObject
public slots:
void listenKeys();
void error(const QString&,const int&);
void error(const int&);
void print(const QString&);
void printList(QStringList&);
void printList(const QStringList&);
// ...
signals:
......@@ -29,24 +31,30 @@ class Controller : public QObject
public:
Controller();
~Controller();
Console* console;
public slots:
void keyPress(const QChar &);
signals:
// to UI
void operate();
void error(const QString&,const int& errCode=0);
void error(const int& errCode=0);
void print(const QString&);
void printList(QStringList&);
void listCams();
void printList(const QStringList&);
// to core
void printHelp();
void printVersion();
void listCams();
void openCam();
void printHelp();
void selectCam(int);
void record();
// void openCam();
// XXX add new func
// void calibrateCam();
// void startRecording();
// void stopRecording();
// void loadSettings();
// void storeSettings();
......
#include "core.h"
#include "../utils.h"
#include "VmbC/VmbCommonTypes.h"
#include "VmbCPP/SharedPointerDefines.h"
#include "frameobserver.h"
#include "../utils.h"
#include <iostream>
#include <vector>
#include <VmbCPP/VmbCPP.h>
#include <VmbCPP/Camera.h>
#include <QDebug>
#include <QThread>
using namespace VmbCPP;
......@@ -15,35 +20,34 @@ Core::Core() :
sys( VmbSystem::GetInstance() ), // Create and get Vimba singleton
cameras( CameraPtrVector() ), // Holds camera handles
camIdx(-1),
curCam(NULL)
curCam(nullptr)
{
if ( VmbErrorSuccess != sys.Startup() )
if ( f(sys.Startup()) )
{
qDebug() << "Couldn't initialize API";
exit(1); //add err code
exit(VmbErrorApiNotStarted);
}
qDebug() << "init API :)"; //emitting signals in ctor doesnt Work, cuz their not connected yet
apiStarted = true;
qDebug() << "init API :)";
initCams();
}
void Core::initCams()
{
if ( VmbErrorSuccess == sys.GetCameras( cameras ) )
if ( f(sys.GetCameras( cameras )))
{
qDebug() << "found " << cameras.size() << " cameras";
qDebug() << "Couldn't get cameras";
}
else
{
qDebug().noquote() << QString("found %1 cameras").arg(cameras.size());
if (cameras.size())
{
camIdx = 0; //dflt to 1rst
curCam = cameras.at(camIdx);
}
}
else
{
qDebug() << "Couldn't get cameras";
}
}
......@@ -57,20 +61,11 @@ Core::~Core()
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()
{
......@@ -85,49 +80,184 @@ void Core::listCams()
std::string str;
QString curCamInfo;
curCamInfo += QString::number(idx+1) + ". ";
if (idx == camIdx )
curCamInfo += "[*]" + DELIM;
else
curCamInfo += "[ ]" + DELIM;
VmbErrorType err = camera->GetID( str );
if( VmbErrorSuccess != err )
str = errorCodeToMessage(err).toStdString();
if( f((camera->GetID( str )))) continue;
curCamInfo += QString::fromStdString(str) + DELIM;
err = camera->GetName( str );
if( VmbErrorSuccess != err )
str = errorCodeToMessage(err).toStdString();
if( f((camera->GetName( str )))) continue;
curCamInfo += QString::fromStdString(str) + DELIM;
err = camera->GetModel( str );
if( VmbErrorSuccess != err )
str = errorCodeToMessage(err).toStdString();
if( f((camera->GetModel( str )))) continue;
curCamInfo += QString::fromStdString(str) + DELIM;
err = camera->GetSerialNumber( str );
if( VmbErrorSuccess != err )
str = errorCodeToMessage(err).toStdString();
if( f((camera->GetSerialNumber( str )))) continue;
curCamInfo += QString::fromStdString(str) + DELIM;
err = camera->GetInterfaceID( str );
if( VmbErrorSuccess != err )
str = errorCodeToMessage(err).toStdString();
if( f((camera->GetInterfaceID( str )))) continue;
curCamInfo += QString::fromStdString(str) + DELIM;
curCamInfo += "closed"; //initially cams are closed, right? XXX how to find out?
curCamInfo += "closed";
// need to update open / closed states.
//initially cams are closed, right? XXX how to find out?
//XXX track states
//VmbSystem::RegisterCameraListObserver
allCamInfo << curCamInfo;
idx++;
}
// qDebug() << __LINE__ << "-" << __PRETTY_FUNCTION__ << allCamInfo;
emit camsListed(allCamInfo);
emit print(QString("found " + QString::number(cameras.size()) + " cameras"));
emit printList(allCamInfo);
}
void Core::printVersion()
{
auto version = getVersionString();
emit versionPrinted(version);
auto version = getVersions();
emit printList(version);
}
void Core::printHelp()
{
//sa Controller::keyPress
QStringList str;
str << "HELP!"
<< "-------------------------------"
<< "h: print this help"
<< "1-9: select camera"
<< "o: open selected camera"
// XXX add new func
<< "r: start recording"
<< "l: list available cameras"
<< "v: print versions"
<< "q: quit"
<< "-------------------------------";
emit printList(str);
}
bool Core::f(const VmbErrorType& ret, const QString& msg)
{
//vimba function wrapper to test return type and potentially emit error message or successmsg
// returns true on error
if( VmbErrorSuccess == ret )
{
if (! msg.isEmpty())
emit print(msg);
return false;
}
else
{
if (! msg.isEmpty())
emit print("Fail! " + msg);
emit error(ret);
return true;
}
}
bool Core::openCam()
{
if(!curCam)
{
emit error(errCamIdx);
return false;
}
return f(curCam->Open( VmbAccessModeFull ),"open cam #"+QString::number(camIdx+1));
}
void Core::selectCam(const int& camIdx)
{
try
{
curCam = cameras.at(camIdx);
}
catch (const std::out_of_range& oor)
{
emit error(errCamIdx);
return;
}
emit print("camSelected("+QString::number(camIdx)+")");
}
void Core::record()
{
//TODO use exceptions to not clutter error handling code here and catch em in main
// TODO
// if( !curCam->isOpen() )
// return; >> listener
VmbInt64_t nPLS; // Payload size value
FeaturePtr pFeature ; // Generic feature pointer
auto nFrames = 5;
FramePtrVector frames(nFrames); // Frame array
// Get the image size for the required buffer
if ( f(curCam->GetFeatureByName ("PayloadSize", pFeature ),"get PayloadSize") )
return; // emit error("Couldn't get payload size 1");
// if( pFeature == nullptr )
// return; // emit error("Couldn't get payload size 2");
if( f(pFeature->GetValue (nPLS)))
return;
qDebug() << "nPLS: " << nPLS;
// Allocate memory for frame buffer
// Register frame observer / callback for each frame
// Announce frame to the API
for( auto& frame : frames )
{
frame.reset(new Frame(nPLS));
f(frame->RegisterObserver( IFrameObserverPtr( new FrameObserver(curCam) )),"register frame observer");
f(curCam->AnnounceFrame(frame), "announce frame");
}
// Start the capture engine (API)
f(curCam->StartCapture(), "start capture");
for( auto frame : frames )
f(curCam->QueueFrame(frame),"QueueFrame"); // Put frame into the frame queue
// if( !frame ) error("frame is null");
// Start the acquisition engine ( curCam)
f(curCam->GetFeatureByName ("AcquisitionStart", pFeature ),"get AcquisitionStart");
// curCam->StartContinuousImageAcquisition(int bufferCount, const IFrameObserverPtr &pObserver)
f(pFeature->RunCommand(),"run AcquisitionStart");
// pFeature ->IsCommandDone(bool &isDone)
// pFeature ->
// Program runtime
QThread::sleep(2);
// Stop the acquisition engine ( curCam)
f(curCam->GetFeatureByName ("AcquisitionStop", pFeature ),"get AcquisitionStop");
f(pFeature->RunCommand(),"run AcquisitionStop");
// Stop the capture engine (API)
// Flush the frame queue
// Revoke all frames from the API
f(curCam->EndCapture(),"end capture");
f(curCam->FlushQueue(),"flush queue");
f(curCam->RevokeAllFrames(),"revoke all frames");
for( FramePtr frame : frames )
{
qDebug() << __LINE__ << "-" << __PRETTY_FUNCTION__ << " frame:" << frame;
// Unregister the frame observer / callback
f(frame->UnregisterObserver(),"unregister observer");
}
qDebug() << __LINE__ << "-" << __PRETTY_FUNCTION__ << "";
}
#pragma once
#include "VmbCPP/SharedPointerDefines.h"
#include "qglobal.h"
#include <QObject>
#include <VmbCPP/SharedPointerDefines.h>
#include <VmbCPP/Interface.h>
namespace VmbCPP {
......@@ -19,19 +19,26 @@ class Core : public QObject
~Core();
public slots:
void listCams();
void printVersion();
void printHelp();
void listCams();
bool openCam();
void selectCam(const int &);
CameraPtr cam(); // make getter seetter -> rm curCam and camIdx //or make Camera class wrapper
void record();
signals:
void camsListed(QStringList &);
void versionPrinted(const QString &);
// ... more signals here
void print(const QString &);
void printList(QStringList);
void error(const int&);
void error(const QString&,const int& errCode=0);
private:
bool f(const VmbErrorType&, const QString& = "");
void initCams();
static void getCamInfo( const CameraPtr & );
CameraPtr cam();
void setCam(ulong idx);
void getCamInfo( const CameraPtr & );
bool apiStarted;
VmbCPP::VmbSystem& sys;
......
#include "frameobserver.h"
#include "frameprocessor.h"
#include "qnamespace.h"
#include <VmbCPP/SharedPointerDefines.h>
#include <VmbCPP/Camera.h>
#include <QDebug>
#include <QThread>
#include <QObject>
using namespace VmbCPP;
FrameObserver::FrameObserver( CameraPtr pCamera ) : IFrameObserver( pCamera )
{
// static int count=0;
// qDebug() << __LINE__ << "-" << __PRETTY_FUNCTION__ << " #:" << count++
}
// Frame callback notifies about incoming frames
// process data afap
// some functions are prohibited within this callback!
// Do not apply image processing within this callback ( performance )
// -> create frame processor to handle frame processing asynchronously
// When the frame has been processed , requeue it
void FrameObserver::FrameReceived ( const FramePtr pframe )
{
qDebug() << __LINE__ << "-" << __PRETTY_FUNCTION__ << "";
FrameProcessor *processor = new FrameProcessor(pframe, this);
QThread *thread = new QThread;
processor->moveToThread(thread);
connect(thread, &QThread::started, processor, &FrameProcessor::processFrame);
connect(processor, &FrameProcessor::frameProcessed, processor, &FrameProcessor::deleteLater);
connect(processor, &FrameProcessor::frameProcessed, thread, &QThread::quit);
connect(processor, &FrameProcessor::frameProcessed, this, &FrameObserver::queueFrame); // Connect to a slot in FrameObserver
connect(thread, &QThread::finished, thread, &QThread::deleteLater);
thread->start();
m_pCamera->QueueFrame( pframe );
}
void FrameObserver::queueFrame(FramePtr pFrame)
{
m_pCamera->QueueFrame(pFrame); // Queue the frame back to the camera
}
#pragma once
#include <QObject>
#include <VmbCPP/IFrameObserver.h>
// using VmbCPP::CameraPtr;
// using VmbCPP::FramePtr;
// using VmbCPP::IFrameObserver;
using namespace VmbCPP;
class FrameObserver : public QObject, public IFrameObserver
{
Q_OBJECT
public:
void FrameReceived( const FramePtr pFrame );
FrameObserver( CameraPtr pCamera );
private slots:
void queueFrame(FramePtr pFrame);
};
#include "frameprocessor.h"
#include "opencv2/imgcodecs.hpp"
#include <opencv2/opencv.hpp>
#include <VmbC/VmbCommonTypes.h>
#include <VmbCPP/Frame.h>
#include <QDebug>
#include <QThread>
#include <QObject>
#include <QImage>
FrameProcessor::FrameProcessor(FramePtr pframe, QObject *parent) : QObject(parent), m_pframe(pframe)
{}
//2d check image format!
//2d add camera name to filename
/// Process the received frame asynchronously
void FrameProcessor::processFrame()
{
// process frames receiveStatus
VmbFrameStatusType status;
m_pframe->GetReceiveStatus(status);
if (status != VmbFrameStatusComplete)
{
qDebug() << "Frame not complete, skip processing.";
return;
}
VmbUint32_t width = 0;
VmbUint32_t height = 0;
unsigned char* pdata;
VmbPixelFormatType pixelFormat;
VmbUint64_t timestamp;
m_pframe->GetWidth(width);
m_pframe->GetHeight(height);
m_pframe->GetBuffer(pdata);
m_pframe->GetPixelFormat(pixelFormat);
m_pframe->GetTimestamp(timestamp);
cv::Mat frameMat(height, width, CV_8UC3, pdata);
if (pixelFormat == VmbPixelFormatRgb8)
{
// If the frame pixel format is RGB8, directly copy the data
// memcpy(frameMat.data, pData, width * height * 3);
qDebug() << "Pixel format is RGB8";
}
else
{
// If the pixel format is not already in BGR format, you may need to convert it
// cv::Mat tempMat(height, width, CV_8UC1, pdata); //UC1??
// cv::cvtColor(tempMat, frameMat, cv::COLOR_BayerGB2BGR); // Adjust the conversion based on the actual Bayer pattern
qDebug() << "Pixel format is not RGB8, converting to BGR";
}
std::vector<int> params = {cv::IMWRITE_JPEG_QUALITY, 99, cv::IMWRITE_JPEG_OPTIMIZE, 1, cv::IMWRITE_JPEG_RST_INTERVAL,4};
QString filename = QString::number(timestamp) + "frame.jpg";
cv::imwrite(filename.toStdString(), frameMat, params);
qDebug() << "Frame saved as JPEG: " << filename;
emit frameProcessed(m_pframe);
}
#include <QObject>
#include <VmbCPP/SharedPointerDefines.h>
using VmbCPP::FramePtr;
class FrameProcessor : public QObject
{
Q_OBJECT
public:
explicit FrameProcessor(FramePtr, QObject *parent = nullptr);
public slots:
void processFrame();
signals:
void frameProcessed(FramePtr);
private:
FramePtr m_pframe;
};
#include "../utils.h"
#include "console.h"
#include "core.h"
#include <iostream>
#include "qnamespace.h"
#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[])
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
QCoreApplication::setApplicationVersion(getVersionString());
QCoreApplication::setApplicationVersion(getVersion());
QCoreApplication::setApplicationName("recorder");
Controller controller;
Core core;
//ui (controller) -> vmb (core)
QObject::connect(&controller, &Controller::listCams, &core, &Core::listCams);
QObject::connect(&controller, &Controller::printHelp, &core, &Core::printHelp);
QObject::connect(&controller, &Controller::printVersion, &core, &Core::printVersion);
//vmb (core) -> ui (controller)
QObject::connect(&core, &Core::camsListed, &controller, &Controller::printList);
QObject::connect(&core, &Core::versionPrinted, &controller, &Controller::print);
QObject::connect(&controller, &Controller::listCams, &core, &Core::listCams);
QObject::connect(&controller, &Controller::openCam, &core, &Core::openCam);
QObject::connect(&controller, &Controller::selectCam, &core, &Core::selectCam);
QObject::connect(&controller, &Controller::record, &core, &Core::record);
// XXX add new func
//vmb (core) -> ui (controller.console)
QObject::connect(&core, SIGNAL(error(const QString&, const int&)), controller.console, SLOT(error(const QString&, const int&)),Qt::DirectConnection);
QObject::connect(&core, SIGNAL(error(const int&)), controller.console, SLOT(error(const int&)),Qt::DirectConnection);
QObject::connect(&core, SIGNAL(print(const QString&)), controller.console, SLOT(print(const QString&)),Qt::DirectConnection);
QObject::connect(&core, SIGNAL(printList(const QStringList&)), controller.console, SLOT(printList(const QStringList&)),Qt::DirectConnection);
// sa Controller() for delegating to Console
QTimer::singleShot(0, &controller, SIGNAL(operate()));
QTimer::singleShot(10, &core, SLOT(printVersion())); // for testing
QTimer::singleShot(15, &core, SLOT(listCams())); // for testing
QTimer::singleShot(30, &core, SLOT(listCams())); // for testing
QTimer::singleShot(100, &core, SLOT(openCam())); // for testing
return a.exec();
}
......@@ -98,3 +73,5 @@ bool maybeCreateDir(QDir out_dir)
// {
// maybeCreateDir(parser.value("o"));
// }
......@@ -20,11 +20,11 @@ void FrameObserver::FrameReceived ( const FramePtr pFrame )
void Vimba::RunExample (void)
{
VmbInt64_t nPLS; // Payload size value
FeaturePtr pFeature ; // Generic feature pointer
VmbSystem &sys = VmbSystem :: GetInstance (); // Create and get Vimba singleton
CameraPtrVector cameras ; // Holds camera handles
CameraPtr camera ;
VmbInt64_t nPLS; // Payload size value
FeaturePtr pFeature ; // Generic feature pointer
FramePtrVector frames (15); // Frame array
// Start the API , get and open cameras
......
#include "utils.h"
#include "opencv2/core/version.hpp"
#include <random>
......@@ -6,66 +7,104 @@
#include "VmbCPP/VmbCPP.h"
#include <QString>
#include <QDebug>
#include <QDir>
#include <iostream>
const int APP_VERSION_MAJOR = 0;
const int APP_VERSION_MINOR = 0;
const int APP_VERSION_PATCH = 5;
const int APP_VERSION_PATCH = 6;
using namespace VmbCPP;
const QString getVersionString()
const QString getVersion()
{
VmbVersionInfo_t version;
VmbSystem::GetInstance().QueryVersion(version);
return QString("# Recorder: %1.%2.%3").arg(APP_VERSION_MAJOR).arg(APP_VERSION_MINOR).arg(APP_VERSION_PATCH);
}
const QStringList getVersions()
{
VmbVersionInfo_t version;
VmbSystem::GetInstance().QueryVersion(version);
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);
s += QStringLiteral("# openCV: %1.%2.%3\n").arg(CV_VERSION_MAJOR).arg(CV_VERSION_MINOR).arg(CV_VERSION_REVISION);
QStringList s;
s << "### Versions";
s << QString("# Recorder: %1.%2.%3").arg(APP_VERSION_MAJOR).arg(APP_VERSION_MINOR).arg(APP_VERSION_PATCH);
s << QString("# Vimba: %1.%2.%3").arg(version.major).arg(version.minor).arg(version.patch);
s << QString("# Qt: %1.%2.%3").arg(QT_VERSION_MAJOR).arg(QT_VERSION_MINOR).arg(QT_VERSION_PATCH);
s << QString("# openCV: %1.%2.%3").arg(CV_VERSION_MAJOR).arg(CV_VERSION_MINOR).arg(CV_VERSION_REVISION);
return s;
return s;
}
const QString errorCodeToMessage( VmbError_t err )
{
QString msg = "error: ";
switch( err )
{
default: msg += "Unknown"; break;
case VmbErrorJustInfo: msg = ""; break; //custom
case VmbErrorSuccess: msg = "Success"; break;
case VmbErrorInternalFault: msg += "Unexpected fault in VmbApi or driver."; break;
case VmbErrorApiNotStarted: msg += "API not started."; break;
case VmbErrorNotFound: msg += "Not found."; break;
case VmbErrorBadHandle: msg += "Invalid handle "; break;
case VmbErrorDeviceNotOpen: msg += "Device not open."; break;
case VmbErrorInvalidAccess: msg += "Invalid access."; break;
case VmbErrorBadParameter: msg += "Bad parameter."; break;
case VmbErrorStructSize: msg += "Wrong DLL version."; break;
case VmbErrorMoreData: msg += "More data returned than memory provided."; break;
case VmbErrorWrongType: msg += "Wrong type."; break;
case VmbErrorInvalidValue: msg += "Invalid value."; break;
case VmbErrorTimeout: msg += "Timeout."; break;
case VmbErrorOther: msg += "TL error."; break;
case VmbErrorResources: msg += "Resource not available."; break;
case VmbErrorInvalidCall: msg += "Invalid call."; break;
case VmbErrorNoTL: msg += "TL not loaded."; break;
case VmbErrorNotImplemented: msg += "Not implemented."; break;
case VmbErrorNotSupported: msg += "Not supported."; break;
}
return msg;
QString msg = "⚠️ ";
switch( err )
{
default: msg += "Unknown"; break;
case VmbErrorJustInfo: msg = ""; break; //custom
case VmbErrorSuccess: msg = "success! 😎"; break; //
case VmbErrorInternalFault: msg += "Unexpected fault in VmbApi or driver."; break;
case VmbErrorApiNotStarted: msg += "API not started."; break;
case VmbErrorNotFound: msg += "Not found."; break;
case VmbErrorBadHandle: msg += "Invalid handle "; break;
case VmbErrorDeviceNotOpen: msg += "Device not open."; break;
case VmbErrorInvalidAccess: msg += "Invalid access."; break;
case VmbErrorBadParameter: msg += "Bad parameter."; break;
case VmbErrorStructSize: msg += "Wrong DLL version."; break;
case VmbErrorMoreData: msg += "More data returned than memory provided."; break;
case VmbErrorWrongType: msg += "Wrong type."; break;
case VmbErrorInvalidValue: msg += "Invalid value."; break;
case VmbErrorTimeout: msg += "Timeout."; break;
case VmbErrorOther: msg += "TL error."; break;
case VmbErrorResources: msg += "Resource not available."; break;
case VmbErrorInvalidCall: msg += "Invalid call."; break;
case VmbErrorNoTL: msg += "TL not loaded."; break;
case VmbErrorNotImplemented: msg += "Not implemented."; break;
case VmbErrorNotSupported: msg += "Not supported."; break;
// ------------------------------- own errCodes -------------------------------
case errCamIdx: msg += "Camera index out of range."; break;
}
return msg;
}
QString randomString()
{
QStringList list{"a", "b", "c", "d", "e", "f", "g"};
//, "h", "i", "j", "k", "l", "m"};
std::random_device rd;
std::mt19937 g(rd());
std::shuffle(list.begin(), list.end(), g);
QString randomString = list.join("");
qDebug() << "Random string:" << randomString;
return randomString;
QStringList list{"a", "b", "c", "d", "e", "f", "g"};
//, "h", "i", "j", "k", "l", "m"};
std::random_device rd;
std::mt19937 g(rd());
std::shuffle(list.begin(), list.end(), g);
QString randomString = list.join("");
qDebug() << "Random string:" << randomString;
return randomString;
}
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]";
char c='y';
std::cin >> c;
if( c == 'y' )
{
qDebug() << "u pressed yes";
if( out_dir.mkpath(out_dir.absolutePath())) {
qDebug() << "created out_dir";
}
else
{
std::cerr << "failed to create out_dir '" << out_dir.absolutePath().toStdString() << "'" << std::endl;
return false;
}
}
else
{
qDebug() << "u pressed no";
return false;
}
}
qDebug() << "out_dir: " << out_dir.dirName();
return true;
}
......@@ -4,10 +4,20 @@
#include <QString>
#include "VmbC/VmbCommonTypes.h" //VmbError_t -> cant really fwd-decl typedef...??
const QString getVersionString();
class QDir;
const QStringList getVersions();
const QString getVersion();
const QString errorCodeToMessage( VmbError_t );
QString randomString();
bool maybeCreateDir(QDir);
const QChar DELIM='|';
typedef enum camtronErr
{
errCamIdx = 10, //!< camera index out of range
xx = 11, //!< Unexpected fault in VmbC or driver
} camtronErr;
#endif