[safety] some try catches at points that sometimes fail

This commit is contained in:
Jan Grewe 2025-03-10 11:57:41 +01:00
parent 767f8b7e42
commit 6ef19c2375
3 changed files with 20 additions and 17 deletions

View File

@ -152,10 +152,10 @@ void CameraPreview::validate(QSpinBox *origin, QSpinBox *dest, int limit){
}
int CameraPreview::ensureDivbyfour(int val) {
if (val % 4 != 0) {
int divisor = floor(val / 4);
val = divisor * 4;
}
// if (val % 4 != 0) {
// int divisor = floor(val / 4);
// val = divisor * 4;
// }
return val;
}

View File

@ -40,12 +40,16 @@ void DualcamGrabber::run() {
// auto start = high_resolution_clock::now();
MyImage *img = new MyImage();
// auto stop1 = high_resolution_clock::now();
cameras[0].RetrieveResult( 5000, frame0, Pylon::TimeoutHandling_ThrowException );
// auto stop2 = high_resolution_clock::now();
cameras[1].RetrieveResult( 5000, frame1, Pylon::TimeoutHandling_ThrowException );
// auto stop3 = high_resolution_clock::now();
leftImage.AttachGrabResultBuffer( frame0 );
rightImage.AttachGrabResultBuffer( frame1 );
try {
cameras[0].RetrieveResult( 5000, frame0, Pylon::TimeoutHandling_ThrowException );
// auto stop2 = high_resolution_clock::now();
cameras[1].RetrieveResult( 5000, frame1, Pylon::TimeoutHandling_ThrowException );
// auto stop3 = high_resolution_clock::now();
leftImage.AttachGrabResultBuffer( frame0 );
rightImage.AttachGrabResultBuffer( frame1 );
} catch(const std::exception& e) {
qDebug() << "Grabbing frame failed! " << e.what();
}
if (leftImage.IsValid() && rightImage.IsValid()) {
try {
StitchImage::StitchToRight(leftImage, rightImage, &stitchedImage, errorMessage);

View File

@ -103,16 +103,15 @@ bool DualcamWrapper::exposureTime(double exposure_time, int camindex) {
exposureTime(exposure_time, 0);
exposureTime(exposure_time, 1);
} else {
GenApi::INodeMap& nodemap = getNodemap(camindex);
double d = GenApi::CFloatPtr(nodemap.GetNode("ExposureTime"))->GetValue();
GenApi::INode* n = nodemap.GetNode( "ExposureTime" );
try {
GenApi::CEnumerationPtr(nodemap.GetNode( "ExposureTimeMode" ))->FromString("Standard");
GenApi::INodeMap& nodemap = getNodemap(camindex);
GenApi::INode* n = nodemap.GetNode( "ExposureTime" );
Pylon::CFloatParameter exp_time( n );
exp_time.SetValue( exposure_time );
GenApi::CEnumerationPtr(nodemap.GetNode( "ExposureTimeMode" ))->FromString("Timed");;
} catch (...) {
qWarning() << "Could not set exposure for cam0";
qWarning() << "Could not set exposure for cam " << camindex;
}
Pylon::CFloatParameter exp_time( n );
exp_time.SetValue( exposure_time );
}
}
return false;