Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Bug: camera2DistortionCoef() uses left-camera distortion data instead of right-camera data #1004

Copy link
Copy link

Description

@ZoeZhou111
Issue body actions

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() {
    return cv::Mat(vPinHoleDistorsion1_.size(), 1, CV_32F, vPinHoleDistorsion1_.data());
}

cv::Mat camera2DistortionCoef() {
    return cv::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() {
    return cv::Mat(vPinHoleDistorsion2_.size(), 1, CV_32F, vPinHoleDistorsion2_.data());
}
Reactions are currently unavailable

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    Morty Proxy This is a proxified and sanitized view of the page, visit original site.