You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In include/Settings.h, the getter camera2DistortionCoef() constructs the OpenCV distortion matrix with the size of the right-camera distortion vector, but with the data pointer of the left-camera distortion vector.
cv::Mat camera1DistortionCoef() {
returncv::Mat(vPinHoleDistorsion1_.size(), 1, CV_32F, vPinHoleDistorsion1_.data());
}
cv::Mat camera2DistortionCoef() {
returncv::Mat(vPinHoleDistorsion2_.size(), 1, CV_32F, vPinHoleDistorsion1_.data()); // bug: should be vPinHoleDistorsion2_
}
This looks like a copy-paste error introduced in the initial Settings API.
Affected code path
Settings::precomputeRectificationMaps() calls both getters and passes them to OpenCV stereo rectification:
cv::stereoRectify(..., camera1DistortionCoef(), ..., camera2DistortionCoef(), ...)
cv::initUndistortRectifyMap(..., camera2DistortionCoef(), ...)
So for Camera.type: "PinHole" stereo / stereo-inertial setups that rely on internal rectification (bNeedToRectify_ == true), the right image is undistorted/rectified with the left camera distortion coefficients.
Impact
Incorrect stereo rectification whenever Camera1 and Camera2 distortion parameters differ (common in real stereo rigs).
Possible epipolar misalignment, degraded stereo matching, and worse scale/depth estimates.
If vPinHoleDistorsion1_ and vPinHoleDistorsion2_ ever have different lengths, the cv::Mat header size and underlying buffer length disagree, which is also unsafe.
Suggested fix
cv::Mat camera2DistortionCoef() {
returncv::Mat(vPinHoleDistorsion2_.size(), 1, CV_32F, vPinHoleDistorsion2_.data());
}
In
include/Settings.h, the gettercamera2DistortionCoef()constructs the OpenCV distortion matrix with the size of the right-camera distortion vector, but with the data pointer of the left-camera distortion vector.