add user given camera name to configuration

This commit is contained in:
Jan Grewe 2024-03-13 08:58:45 +01:00
parent 18f088c4fd
commit 155ac6b471
6 changed files with 54 additions and 17 deletions

View File

@ -43,10 +43,10 @@ include_directories (AFTER ${NIX_INCLUDE_DIR})
# ####################################### # #######################################
# OPENCV # OPENCV
message ("=> finding opencv ...") # message ("=> finding opencv ...")
find_package(OpenCV REQUIRED opencv_highgui opencv_core) # find_package(OpenCV REQUIRED opencv_highgui opencv_core)
include_directories(AFTER ${OpenCV_INCLUDE_DIRS} ) # include_directories(AFTER ${OpenCV_INCLUDE_DIRS} )
set(LINK_LIBS ${LINK_LIBS} ${OpenCV_LIBRARIES}) # set(LINK_LIBS ${LINK_LIBS} ${OpenCV_LIBRARIES})
####################################### #######################################
# Pylon # Pylon
@ -58,5 +58,5 @@ file (GLOB RECORDER_SOURCES *.cpp)
file (GLOB RECORDER_INCLUDES *.hpp) file (GLOB RECORDER_INCLUDES *.hpp)
add_executable ( recorder ${RECORDER_SOURCES} ${RECORDER_INCLUDES} ${RECORDER_RES_SOURCES} ) add_executable ( recorder ${RECORDER_SOURCES} ${RECORDER_INCLUDES} ${RECORDER_RES_SOURCES} )
target_include_directories ( recorder PUBLIC "${PROJECT_BINARY_DIR}" ) target_include_directories ( recorder PUBLIC "${PROJECT_BINARY_DIR}" )
target_link_libraries ( recorder Qt5::PrintSupport Qt5::Core Qt5::Widgets Qt5::Gui ${NIX_LIBRARIES} pylon::pylon ${OpenCV_LIBRARIES}) target_link_libraries ( recorder Qt5::PrintSupport Qt5::Core Qt5::Widgets Qt5::Gui ${NIX_LIBRARIES} pylon::pylon)
# ${PYLON_LIBRARIES} ${OpenCV_LIBRARIES}) # ${PYLON_LIBRARIES} ${OpenCV_LIBRARIES})

View File

@ -60,8 +60,7 @@ CameraPreview::CameraPreview(QWidget *parent):cameraname(""), camera(nullptr), Q
void CameraPreview::setCamera(QString &device){ void CameraPreview::setCamera(QString &device){
qDebug() << "update camera! ";// << device.toStdString(); qDebug() << "update camera! ";// << device.toStdString();
cameraname = device; cameraname = device;
label->setText(device); if (camera != nullptr) {
if (camera != NULL) {
qDebug() << "camera is not nullptr! "; qDebug() << "camera is not nullptr! ";
delete camera; delete camera;
camera = nullptr; camera = nullptr;
@ -76,7 +75,9 @@ void CameraPreview::setCamera(QString &device){
QString msg = "<p><b>Could not open camera device!</b><p><p>" + QString::fromStdString(message) + "</p>"; QString msg = "<p><b>Could not open camera device!</b><p><p>" + QString::fromStdString(message) + "</p>";
msgBox.setText(msg); msgBox.setText(msg);
msgBox.exec(); msgBox.exec();
return;
} }
label->setText(device + " - " + camera->userName());
takeStill(); takeStill();
} }

View File

@ -443,6 +443,9 @@ void PylonRecorder::createActions() {
grab_continuous_action->setShortcut(tr("Ctrl+Enter")); grab_continuous_action->setShortcut(tr("Ctrl+Enter"));
grab_stop_action = camera_menu->addAction(stop_icon, tr("&stop grabbing"), this, &PylonRecorder::stopRecording); grab_stop_action = camera_menu->addAction(stop_icon, tr("&stop grabbing"), this, &PylonRecorder::stopRecording);
grab_stop_action->setShortcut(tr("Ctrl+Shift+Enter")); grab_stop_action->setShortcut(tr("Ctrl+Shift+Enter"));
set_cam_identifier_action = camera_menu->addAction(tr("set identifier"), this, &PylonRecorder::setCameraIDs);
set_cam_identifier_action->setStatusTip(tr("Set human readable camera identifier or easier recognition."));
set_cam_identifier_action->setToolTip(tr("Set human readable camera identifier or easier recognition."));
selectStorageAction = new QAction(tr("storage location"), this); selectStorageAction = new QAction(tr("storage location"), this);
selectStorageAction->setStatusTip(tr("Select a storage location for the recorded videos")); selectStorageAction->setStatusTip(tr("Select a storage location for the recorded videos"));
@ -540,9 +543,32 @@ void PylonRecorder::updateActions() {
grab_still_action->setEnabled(cameraOpened); grab_still_action->setEnabled(cameraOpened);
grab_continuous_action->setEnabled(cameraOpened && !grabbing); grab_continuous_action->setEnabled(cameraOpened && !grabbing);
grab_stop_action->setEnabled(grabbing); grab_stop_action->setEnabled(grabbing);
set_cam_identifier_action->setEnabled(false);
} }
void PylonRecorder::setCameraIDs() {
if (deviceList.size() == 0) {
QMessageBox msgBox;
QString msg = "<p><b>No camera device found!</b></p><br><p>Connect camera and try again!</p>";
msgBox.setText(msg);
msgBox.exec();
qWarning() << msg.toStdString().c_str();
return;
}
cameraIdDialog = new CameraID(deviceList, this);
connect(cameraConfigDialog, SIGNAL(accepted()), SLOT(cameraIDAccepted()));
std::cerr <<"ping\n";
cameraIdDialog->exec();
}
void PylonRecorder::cameraIDAccepted() {
QString newid = cameraIdDialog->newID();
int deviceindex = cameraIdDialog->cameraIndex();
std::cerr << "New camera id " << newid.toStdString() << " index: " << deviceindex << std::endl;
delete(cameraIdDialog);
}
void PylonRecorder::scaleImage(double factor) { void PylonRecorder::scaleImage(double factor) {
QPixmap map = imageLabel->pixmap(Qt::ReturnByValue); QPixmap map = imageLabel->pixmap(Qt::ReturnByValue);
Q_ASSERT(!map.isNull()); Q_ASSERT(!map.isNull());
@ -582,19 +608,19 @@ void PylonRecorder::adjustScrollBar(QScrollBar *scrollBar, double factor) {
void PylonRecorder::cameraConfiguration(){ void PylonRecorder::cameraConfiguration(){
d = new CamConfigurator(deviceList, this); cameraConfigDialog = new CamConfigurator(deviceList, this);
connect(d, SIGNAL(accepted()), SLOT(cameraConfigurationAccepted())); connect(cameraConfigDialog, SIGNAL(accepted()), SLOT(cameraConfigurationAccepted()));
connect(d, SIGNAL(rejected()), SLOT(cameraConfigurationAborted())); connect(cameraConfigDialog, SIGNAL(rejected()), SLOT(cameraConfigurationAborted()));
// QObject::connect(&d, SIGNAL(column_visibility_changed(QString, QString,bool)), this, SLOT(visible_columns_update(QString, QString,bool))); // QObject::connect(&d, SIGNAL(column_visibility_changed(QString, QString,bool)), this, SLOT(visible_columns_update(QString, QString,bool)));
d->exec(); cameraConfigDialog->exec();
} }
void PylonRecorder::cameraConfigurationAccepted() { void PylonRecorder::cameraConfigurationAccepted() {
qDebug() << "Cameras setting " << ((d->result()) ? "Accepted" : "Discarded"); qDebug() << "Cameras setting " << ((cameraConfigDialog->result()) ? "Accepted" : "Discarded");
this->layout = d->layout(); this->layout = cameraConfigDialog->layout();
camsconfigured = true; camsconfigured = true;
delete d; delete cameraConfigDialog;
} }

View File

@ -13,9 +13,9 @@
#include "grabber.h" #include "grabber.h"
#include "dualcamgrabber.h" #include "dualcamgrabber.h"
#include "writer.h" #include "writer.h"
#include "opencvwriter.h"
#include "projectsettings.h" #include "projectsettings.h"
#include "camconfig.h" #include "camconfig.h"
#include "camids.h"
#include "util.h" #include "util.h"
#include <QImage> #include <QImage>
@ -71,6 +71,8 @@ private slots:
void selectStorageLocation(); void selectStorageLocation();
void cameraConfigurationAccepted(); void cameraConfigurationAccepted();
void cameraConfigurationAborted(); void cameraConfigurationAborted();
void setCameraIDs();
void cameraIDAccepted();
private: private:
void createActions(); void createActions();
@ -87,7 +89,6 @@ private:
VideoSpecs getVideoSpecs(const ImageSettings &settings); VideoSpecs getVideoSpecs(const ImageSettings &settings);
void startSinglecamRecording(); void startSinglecamRecording();
void startDualcamRecording(); void startDualcamRecording();
bool saveFile(const QString &fileName); bool saveFile(const QString &fileName);
void setImage(const QImage &newImage); void setImage(const QImage &newImage);
void scaleImage(double factor); void scaleImage(double factor);
@ -122,8 +123,9 @@ private:
QString storageLocation = ""; QString storageLocation = "";
ProjectMetadata mdata; ProjectMetadata mdata;
Pylon::DeviceInfoList_t deviceList; Pylon::DeviceInfoList_t deviceList;
CamConfigurator *d;
Pylon::PylonAutoInitTerm autoInitTerm; Pylon::PylonAutoInitTerm autoInitTerm;
CamConfigurator *cameraConfigDialog;
CameraID *cameraIdDialog;
#if defined(QT_PRINTSUPPORT_LIB) && QT_CONFIG(printer) #if defined(QT_PRINTSUPPORT_LIB) && QT_CONFIG(printer)
@ -142,6 +144,7 @@ private:
QAction *grab_stop_action; QAction *grab_stop_action;
QAction *connect_camera_action; QAction *connect_camera_action;
QAction *disconnect_camera_action; QAction *disconnect_camera_action;
QAction *set_cam_identifier_action;
}; };
#endif #endif

View File

@ -232,3 +232,9 @@ void PylonWrapper::closeCamera() {
Pylon::CInstantCamera *PylonWrapper::getCamera() { Pylon::CInstantCamera *PylonWrapper::getCamera() {
return camera; return camera;
} }
QString PylonWrapper::userName() {
GenApi::INodeMap& nodemap = camera->GetNodeMap();
QString username = Pylon::CStringParameter(nodemap, "DeviceUserID").GetValue().c_str();
return username;
}

View File

@ -27,6 +27,7 @@ public:
bool exposureTime(double exposure_time); bool exposureTime(double exposure_time);
double gain(); double gain();
bool gain(double gain_db); bool gain(double gain_db);
QString userName();
Pylon::CInstantCamera *getCamera(); Pylon::CInstantCamera *getCamera();
void resetCamera(); void resetCamera();