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 "mylogger.h"
#include "util.h"
CamConfigurator::CamConfigurator(Pylon::DeviceInfoList_t &deviceList, QWidget *parent) :
deviceList(deviceList), QDialog(parent) {
@ -45,9 +47,12 @@ CamConfigurator::CamConfigurator(Pylon::DeviceInfoList_t &deviceList, QWidget *p
connect(buttonbox, &QDialogButtonBox::rejected, this, &QDialog::reject);
vbox->addWidget(buttonbox);
//this->setLayout(vbox);
// qInfo() << "Create Camera configuration!";
}
QWidget* CamConfigurator::singleCameraView() {
qInfo() << "Create Camera configuration!";
QWidget *w = new QWidget(this);
QVBoxLayout *l = new QVBoxLayout(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()
{
delete singleCamPreview;

View File

@ -8,9 +8,10 @@
#include <QStackedWidget>
#include <QGridLayout>
#include <pylon/PylonIncludes.h>
#include "camerapreview.h"
class ROI;
namespace Ui {
class CamConfigurator;
}
@ -23,6 +24,8 @@ public:
explicit CamConfigurator(Pylon::DeviceInfoList_t &deviceList, QWidget *parent = 0);
~CamConfigurator();
CameraLayout layout();
public slots:
void modeChanged(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 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(){
std::cerr << "cameraPreview destructor" << std::endl;
if (camera != nullptr){

View File

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

View File

@ -21,7 +21,7 @@
#include <iostream>
#include <chrono>
#include <cmath>
#include "camconfig.h"
#include "util.h"
#if defined(QT_PRINTSUPPORT_LIB)
# include <QtPrintSupport/qtprintsupportglobal.h>
@ -548,6 +548,7 @@ void PylonRecorder::createActions() {
void PylonRecorder::updateActions() {
qInfo() << "Update Actions";
saveAsAct->setEnabled(!image.isNull());
copyAct->setEnabled(!image.isNull());
zoomInAct->setEnabled(!fitToWindowAct->isChecked());
@ -581,15 +582,13 @@ void PylonRecorder::applyScaling(){
void PylonRecorder::quitApplication() {
std::cerr << "Quit Application!" << std::endl;
// if (pyloncam->isOpen()) {
// std::cerr << "Cam is open!" << std::endl;
std::cerr << "Stop grabbing" << std::endl;
qDebug() << "Quit Application!";
if (grabbing) {
qDebug() << "QuitApplication: Stop grabbing";
stopRecording();
}
std::cerr << "done!" << std::endl;
qDebug() << "QuitApplication done!";
this->close();
}
@ -609,6 +608,8 @@ void PylonRecorder::cameraConfiguration(){
void PylonRecorder::camerasetup() {
std::cerr << "camera settings accepted" << std::endl;
std::cerr << d->result() << std::endl;
CameraLayout l = d->layout();
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>";
msgBox.setText(msg);
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 {
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();
} else { // more than 1 camera
} else {
// 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 {
// 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();
}
}
@ -700,37 +700,30 @@ void PylonRecorder::startRecording() {
void PylonRecorder::stopRecording() {
std::cerr << "StopRecording!" << std::endl;
qDebug() << "StopRecording!";
if (!stopRequest) {
std::cerr << "StopRecording2!" << std::endl;
qDebug() << "StopRecording: stop frame timer!";
frameTimer->stop();
std::cerr << "StopRecording3!" << std::endl;
qDebug() << "StopRecording: stop grabber!";
if (grabber !=nullptr)
grabber->requestStop();
std::cerr << "StopRecording4!" << std::endl;
qDebug() << "StopRecording: stop writer!";
if (writer != nullptr)
writer->requestStop();
std::cerr << "StopRecording5!" << std::endl;
grabbing = false;
stopRequest = true;
grab_stop_action->setEnabled(false);
std::cerr << "stop recording buffer" << buffer << std::endl;
qDebug() << "StopRecording: clear buffer!";
if(buffer != nullptr) {
std::cerr << "stop recording buffer" << buffer << std::endl;
buffer->clear();
writerDone();
}
}
std::cerr << "StopRecording done!" << std::endl;
qDebug() << "StopRecording done!";
}
void PylonRecorder::writerDone() {
std::cerr << "writerDone slot!" << std::endl;
preassureTimer->stop();
preassureBar->reset();
loadBar->reset();
@ -741,8 +734,7 @@ void PylonRecorder::writerDone() {
writer->wait(10000);
writing = false;
updateActions();
std::cerr << "writerDone slot done!" << std::endl;
qInfo() << "writer is Done!";
}