Purpose of scaling disparity in stereo vision

44 Views Asked by At

This code calculates the disparity of two left and right stereo camera images (github link to the complete code and used images).

I do not understand why the disparity is scaled by (1/16) in disparity_sgbm.convertTo(disparity, CV_32F, 1.0 / 16.0f);.

int main(int argc, char **argv) {

    // 内参
    double fx = 718.856, fy = 718.856, cx = 607.1928, cy = 185.2157;
    // 基线
    double b = 0.573;

    // 读取图像
    cv::Mat left = cv::imread(left_file, 0);
    cv::Mat right = cv::imread(right_file, 0);
    cv::Ptr<cv::StereoSGBM> sgbm = cv::StereoSGBM::create(
        0, 96, 9, 8 * 9 * 9, 32 * 9 * 9, 1, 63, 10, 100, 32);    // 神奇的参数
    cv::Mat disparity_sgbm, disparity;
    sgbm->compute(left, right, disparity_sgbm);
    disparity_sgbm.convertTo(disparity, CV_32F, 1.0 / 16.0f);
0

There are 0 best solutions below