fix resetting resolutions, not fully working yet

This commit is contained in:
Jan Grewe 2024-03-07 17:07:53 +01:00
parent 96effc81c5
commit 63231e5a1c
2 changed files with 15 additions and 7 deletions

View File

@ -3,7 +3,7 @@
#include "util.h"
CamConfigurator::CamConfigurator(Pylon::DeviceInfoList_t &deviceList, QWidget *parent) :
CamConfigurator::CamConfigurator(Pylon::DeviceInfoList &deviceList, QWidget *parent) :
deviceList(deviceList), QDialog(parent), preview(nullptr) {
mode_combo = new QComboBox(this);
mode_combo->addItem("camera mode");

View File

@ -140,6 +140,7 @@ ImageSettings PylonWrapper::getImageSettings() {
bool PylonWrapper::grabFrame(MyImage &img) {
Pylon::CGrabResultPtr frame;
qDebug() << "grabFrame";
if (valid) {
qDebug() << "Setting width" << layout.rois[0].width;
Pylon::CIntegerParameter(camera->GetNodeMap(), "Width").SetValue(layout.rois[0].width);
@ -159,13 +160,20 @@ bool PylonWrapper::grabFrame(MyImage &img) {
}
void PylonWrapper::resetCamera() {
std::string n = std::string(Pylon::CStringParameter(camera->GetNodeMap(), "DeviceUserID").GetValue());
int64_t maxWidth = 2048;
int64_t maxHeight = 1536;
Pylon::CIntegerParameter(camera->GetNodeMap(), "Width").SetValue(maxWidth);
Pylon::CIntegerParameter(camera->GetNodeMap(), "Height").SetValue(maxHeight);
Pylon::CIntegerParameter(camera->GetNodeMap(), "OffsetX").SetValue(0);
Pylon::CIntegerParameter(camera->GetNodeMap(), "OffsetY").SetValue(0);
qDebug() << "resetting camera to default ROI (" << maxWidth << ", " << maxHeight << ")";
try {
GenApi::INodeMap& nodemap = camera->GetNodeMap();
Pylon::CIntegerParameter(nodemap, "Width").SetValue(maxWidth);
Pylon::CIntegerParameter(nodemap, "Height").SetValue(maxHeight);
Pylon::CIntegerParameter(nodemap, "OffsetX").SetValue(0);
Pylon::CIntegerParameter(nodemap, "OffsetY").SetValue(0);
} catch (const Pylon::GenericException &e) {
std::string message = e.GetDescription();
std::cerr << "An exception occurred." << std::endl << e.GetDescription() << std::endl;
valid = false;
}
}
bool PylonWrapper::openCamera(std::string &message) {
@ -178,7 +186,6 @@ bool PylonWrapper::openCamera(std::string &message) {
Pylon::IPylonDevice *pDevice = Pylon::CTlFactory::GetInstance().CreateDevice(fname);
camera->Attach(pDevice);
camera->Open();
resetCamera();
valid = camera->IsOpen();
message = "Successfully opened camera!";
} catch (const Pylon::GenericException &e) {
@ -187,6 +194,7 @@ bool PylonWrapper::openCamera(std::string &message) {
valid = false;
return valid;
}
resetCamera();
if (!withLayout) {
qDebug() << "opening camera without layout, creating a new one";
ImageSettings s = getImageSettings();