diff --git a/components/rgbd-sources/src/sources/stereovideo/pylon.cpp b/components/rgbd-sources/src/sources/stereovideo/pylon.cpp index 33acac1148e78eca9d1cf352a7630bd109885522..47b568d86761eb393d37c494cb77734b3ffc5aad 100644 --- a/components/rgbd-sources/src/sources/stereovideo/pylon.cpp +++ b/components/rgbd-sources/src/sources/stereovideo/pylon.cpp @@ -50,9 +50,9 @@ PylonDevice::PylonDevice(nlohmann::json &config) } if (dev_left_num == i) { - LOG(INFO) << " - found Pylon device - " << d.GetSerialNumber() << "(" << d.GetModelName() << ") [primary]"; + LOG(INFO) << " - found Pylon device - " << d.GetSerialNumber() << " (" << d.GetModelName() << ") [primary]"; } else { - LOG(INFO) << " - found Pylon device - " << d.GetSerialNumber() << "(" << d.GetModelName() << ")"; + LOG(INFO) << " - found Pylon device - " << d.GetSerialNumber() << " (" << d.GetModelName() << ")"; } ++i; @@ -147,8 +147,11 @@ void PylonDevice::_configureCamera(CBaslerUniversalInstantCamera *cam) { LOG(WARNING) << "Could not change pixel format"; } - cam->ExposureTime.SetValue(24000.0f); // Exposure time in microseconds - cam->LightSourcePreset.SetValue(Basler_UniversalCameraParams::LightSourcePreset_Tungsten2800K); // White balance option + if (cam->GetDeviceInfo().GetModelName() != "Emulation") { + // Emulated device throws exception with these + cam->ExposureTime.SetValue(24000.0f); // Exposure time in microseconds + cam->LightSourcePreset.SetValue(Basler_UniversalCameraParams::LightSourcePreset_Tungsten2800K); // White balance option + } } bool PylonDevice::grab() { diff --git a/components/rgbd-sources/src/sources/stereovideo/rectification.cpp b/components/rgbd-sources/src/sources/stereovideo/rectification.cpp index cf211c858a02986825a381ee572d00dc37b2107a..3f518dff3b207c2cd02c5492a6f29d1bc67a9852 100644 --- a/components/rgbd-sources/src/sources/stereovideo/rectification.cpp +++ b/components/rgbd-sources/src/sources/stereovideo/rectification.cpp @@ -28,7 +28,9 @@ StereoRectification::StereoRectification(nlohmann::json &config, cv::Size image_ void StereoRectification::setSize(cv::Size size) { image_resolution_ = size; - calculateParameters(); + if (calibrated()) { + calculateParameters(); + } } void StereoRectification::setInterpolation(int interpolation) { @@ -64,13 +66,18 @@ void StereoRectification::setCalibration(const CalibrationData &calib) { void StereoRectification::calculateParameters() { using namespace ftl::calibration; // TODO: lock + { + bool valid = true; + valid &= calib_left_.intrinsic.resolution != cv::Size{0, 0}; + valid &= calib_right_.intrinsic.resolution != cv::Size{0, 0}; + valid &= calib_left_.intrinsic.distCoeffs.size() != 0; + valid &= calib_right_.intrinsic.distCoeffs.size() != 0; + valid &= validate::cameraMatrix(calib_left_.intrinsic.matrix()); + valid &= validate::cameraMatrix(calib_right_.intrinsic.matrix()); + if (!valid) { return; } + } + valid_ = false; - bool valid = true; - valid_ &= !calib_left_.intrinsic.resolution.empty(); - valid_ &= !calib_right_.intrinsic.resolution.empty(); - valid_ &= validate::cameraMatrix(calib_left_.intrinsic.matrix()); - valid_ &= validate::cameraMatrix(calib_right_.intrinsic.matrix()); - if (!valid) { return; } // create temporary buffers if (tmp_l_.size() != image_resolution_) { @@ -104,9 +111,8 @@ void StereoRectification::calculateParameters() { cv::Mat R; cv::Mat t; transform::getRotationAndTranslation(T, R, t); - baseline_ = cv::norm(t); - if (baseline_ == 0) { return; } + if (baseline_ == 0.0) { return; } // calculate rectification parameters cv::stereoRectify( K_l, dc_l, K_r, dc_r, image_resolution_,