getter for camera layout

This commit is contained in:
Jan Grewe 2023-11-10 18:45:06 +01:00
parent cd316cf606
commit d7b64790e4
5 changed files with 65 additions and 40 deletions

View File

@ -1,4 +1,6 @@
#include "camconfig.h" #include "camconfig.h"
#include "mylogger.h"
#include "util.h"
CamConfigurator::CamConfigurator(Pylon::DeviceInfoList_t &deviceList, QWidget *parent) : CamConfigurator::CamConfigurator(Pylon::DeviceInfoList_t &deviceList, QWidget *parent) :
deviceList(deviceList), QDialog(parent) { deviceList(deviceList), QDialog(parent) {
@ -45,9 +47,12 @@ CamConfigurator::CamConfigurator(Pylon::DeviceInfoList_t &deviceList, QWidget *p
connect(buttonbox, &QDialogButtonBox::rejected, this, &QDialog::reject); connect(buttonbox, &QDialogButtonBox::rejected, this, &QDialog::reject);
vbox->addWidget(buttonbox); vbox->addWidget(buttonbox);
//this->setLayout(vbox); //this->setLayout(vbox);
// qInfo() << "Create Camera configuration!";
} }
QWidget* CamConfigurator::singleCameraView() { QWidget* CamConfigurator::singleCameraView() {
qInfo() << "Create Camera configuration!";
QWidget *w = new QWidget(this); QWidget *w = new QWidget(this);
QVBoxLayout *l = new QVBoxLayout(w); QVBoxLayout *l = new QVBoxLayout(w);
l->setParent(w); l->setParent(w);
@ -80,6 +85,18 @@ void CamConfigurator::primaryDeviceChanged(int idx) {
} }
} }
CameraLayout CamConfigurator::layout(){
CameraLayout l;
if (mode_combo->currentText() == "single camera") {
l.mode = CameraMode::single;
l.layout = Layout::horizontal;
l.devices.push_back(device_combo->currentText().toStdString());
l.rois.push_back(singleCamPreview->getRoi());
} else {
qWarning() << "not implemented yet";
}
return l;
}
CamConfigurator::~CamConfigurator() CamConfigurator::~CamConfigurator()
{ {
delete singleCamPreview; delete singleCamPreview;

View File

@ -8,9 +8,10 @@
#include <QStackedWidget> #include <QStackedWidget>
#include <QGridLayout> #include <QGridLayout>
#include <pylon/PylonIncludes.h> #include <pylon/PylonIncludes.h>
#include "camerapreview.h" #include "camerapreview.h"
class ROI;
namespace Ui { namespace Ui {
class CamConfigurator; class CamConfigurator;
} }
@ -23,6 +24,8 @@ public:
explicit CamConfigurator(Pylon::DeviceInfoList_t &deviceList, QWidget *parent = 0); explicit CamConfigurator(Pylon::DeviceInfoList_t &deviceList, QWidget *parent = 0);
~CamConfigurator(); ~CamConfigurator();
CameraLayout layout();
public slots: public slots:
void modeChanged(int idx); void modeChanged(int idx);
void primaryDeviceChanged(int idx); void primaryDeviceChanged(int idx);

View File

@ -126,6 +126,17 @@ void CameraPreview::updateROI(QString v){
// FIXME same for y offset and height // FIXME same for y offset and height
// FIXME initialize the cameras // FIXME initialize the cameras
ROI CameraPreview::getRoi() {
ROI r;
r.x = xoffs->value();
r.y = yoffs->value();
r.width = width->value();
r.height = height->value();
r.height = r.height > 1536 ? 1536 - r.y : r.height;
r.width = r.width > 2048 ? 2048 - r.x : r.width;
return r;
}
CameraPreview::~CameraPreview(){ CameraPreview::~CameraPreview(){
std::cerr << "cameraPreview destructor" << std::endl; std::cerr << "cameraPreview destructor" << std::endl;
if (camera != nullptr){ if (camera != nullptr){

View File

@ -13,7 +13,7 @@
#include <pylon/PylonIncludes.h> #include <pylon/PylonIncludes.h>
#include "pylonwrapper.h" #include "pylonwrapper.h"
#include "util.h"
namespace Ui { namespace Ui {
class CameraPreview; class CameraPreview;
} }
@ -26,6 +26,8 @@ public:
explicit CameraPreview(QString &devicename, QWidget *parent = 0); explicit CameraPreview(QString &devicename, QWidget *parent = 0);
~CameraPreview(); ~CameraPreview();
ROI getRoi();
public slots: public slots:
void updateCamera(QString &device); void updateCamera(QString &device);
void updateROI(QString v); void updateROI(QString v);

View File

@ -21,7 +21,7 @@
#include <iostream> #include <iostream>
#include <chrono> #include <chrono>
#include <cmath> #include <cmath>
#include "camconfig.h" #include "util.h"
#if defined(QT_PRINTSUPPORT_LIB) #if defined(QT_PRINTSUPPORT_LIB)
# include <QtPrintSupport/qtprintsupportglobal.h> # include <QtPrintSupport/qtprintsupportglobal.h>
@ -548,6 +548,7 @@ void PylonRecorder::createActions() {
void PylonRecorder::updateActions() { void PylonRecorder::updateActions() {
qInfo() << "Update Actions";
saveAsAct->setEnabled(!image.isNull()); saveAsAct->setEnabled(!image.isNull());
copyAct->setEnabled(!image.isNull()); copyAct->setEnabled(!image.isNull());
zoomInAct->setEnabled(!fitToWindowAct->isChecked()); zoomInAct->setEnabled(!fitToWindowAct->isChecked());
@ -581,15 +582,13 @@ void PylonRecorder::applyScaling(){
void PylonRecorder::quitApplication() { void PylonRecorder::quitApplication() {
std::cerr << "Quit Application!" << std::endl; qDebug() << "Quit Application!";
// if (pyloncam->isOpen()) {
// std::cerr << "Cam is open!" << std::endl;
std::cerr << "Stop grabbing" << std::endl;
if (grabbing) { if (grabbing) {
qDebug() << "QuitApplication: Stop grabbing";
stopRecording(); stopRecording();
} }
std::cerr << "done!" << std::endl; qDebug() << "QuitApplication done!";
this->close(); this->close();
} }
@ -609,6 +608,8 @@ void PylonRecorder::cameraConfiguration(){
void PylonRecorder::camerasetup() { void PylonRecorder::camerasetup() {
std::cerr << "camera settings accepted" << std::endl; std::cerr << "camera settings accepted" << std::endl;
std::cerr << d->result() << std::endl; std::cerr << d->result() << std::endl;
CameraLayout l = d->layout();
delete d; delete d;
} }
@ -619,23 +620,22 @@ void PylonRecorder::connectCamera() {
QString msg = "<p><b>No camera device found!</b></p><br><p>Connect camera and try again!</p>"; QString msg = "<p><b>No camera device found!</b></p><br><p>Connect camera and try again!</p>";
msgBox.setText(msg); msgBox.setText(msg);
msgBox.exec(); msgBox.exec();
} else if (deviceList.size() == 1) {
std::string cname = (std::string)deviceList[0].GetFullName();
pyloncam = new PylonWrapper(cname);
std::string message;
bool success = pyloncam->openCamera(message);
if (success) {
cameraConnectedLabel->setText("connected");
cameraConnectedLabel->setStyleSheet("QLabel { font-size: 10px;font-family: Arial;color: green;}");
} else { } else {
QMessageBox msgBox; // std::string cname = (std::string)deviceList[0].GetFullName();
QString msg = "<p><b>Could not open camera device!</b><p><p>" + QString::fromStdString(message) + "</p>"; // pyloncam = new PylonWrapper(cname);
msgBox.setText(msg); // std::string message;
msgBox.exec(); // bool success = pyloncam->openCamera(message);
} // if (success) {
statusBar()->showMessage(QString::fromStdString(message)); // cameraConnectedLabel->setText("connected");
updateActions(); // cameraConnectedLabel->setStyleSheet("QLabel { font-size: 10px;font-family: Arial;color: green;}");
} else { // more than 1 camera // } else {
// QMessageBox msgBox;
// QString msg = "<p><b>Could not open camera device!</b><p><p>" + QString::fromStdString(message) + "</p>";
// msgBox.setText(msg);
// msgBox.exec();
// }
// statusBar()->showMessage(QString::fromStdString(message));
// updateActions();
cameraConfiguration(); cameraConfiguration();
} }
} }
@ -700,37 +700,30 @@ void PylonRecorder::startRecording() {
void PylonRecorder::stopRecording() { void PylonRecorder::stopRecording() {
std::cerr << "StopRecording!" << std::endl; qDebug() << "StopRecording!";
if (!stopRequest) { if (!stopRequest) {
std::cerr << "StopRecording2!" << std::endl; qDebug() << "StopRecording: stop frame timer!";
frameTimer->stop(); frameTimer->stop();
std::cerr << "StopRecording3!" << std::endl; qDebug() << "StopRecording: stop grabber!";
if (grabber !=nullptr) if (grabber !=nullptr)
grabber->requestStop(); grabber->requestStop();
std::cerr << "StopRecording4!" << std::endl; qDebug() << "StopRecording: stop writer!";
if (writer != nullptr) if (writer != nullptr)
writer->requestStop(); writer->requestStop();
std::cerr << "StopRecording5!" << std::endl;
grabbing = false; grabbing = false;
stopRequest = true; stopRequest = true;
grab_stop_action->setEnabled(false); grab_stop_action->setEnabled(false);
std::cerr << "stop recording buffer" << buffer << std::endl; qDebug() << "StopRecording: clear buffer!";
if(buffer != nullptr) { if(buffer != nullptr) {
std::cerr << "stop recording buffer" << buffer << std::endl;
buffer->clear(); buffer->clear();
writerDone(); writerDone();
} }
} }
std::cerr << "StopRecording done!" << std::endl; qDebug() << "StopRecording done!";
} }
void PylonRecorder::writerDone() { void PylonRecorder::writerDone() {
std::cerr << "writerDone slot!" << std::endl;
preassureTimer->stop(); preassureTimer->stop();
preassureBar->reset(); preassureBar->reset();
loadBar->reset(); loadBar->reset();
@ -741,8 +734,7 @@ void PylonRecorder::writerDone() {
writer->wait(10000); writer->wait(10000);
writing = false; writing = false;
updateActions(); updateActions();
std::cerr << "writerDone slot done!" << std::endl; qInfo() << "writer is Done!";
} }