diff --git a/camconfig.cpp b/camconfig.cpp index 2d78246..ef72240 100644 --- a/camconfig.cpp +++ b/camconfig.cpp @@ -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"); diff --git a/pylonwrapper.cpp b/pylonwrapper.cpp index ab00732..10a4e0b 100644 --- a/pylonwrapper.cpp +++ b/pylonwrapper.cpp @@ -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();