Search code examples
c++opencvdisparity-mapping

missing region in disparity map


i am currently working on stereo processing using opencv2.3 and a Pointgrey Bumblebee2 stereocamera as an input device. Acquiring images is done via the libdc1394.

My code for rectification and stereo processing is the following:

void StereoProcessing::calculateDisparityMap(const Mat &left, const Mat &right, Mat &disparity_map)

  Mat map11, map12, map21, map22, left_rectified, right_rectified, disp16;

  // Computes the undistortion and rectification transformation maps
  initUndistortRectifyMap(this->camera_matrix1,
        this->distance_coefficients1,
        this->R1,
        this->P1,
        this->output_image_size,
        CV_16SC2,
        map11,
        map12);
  initUndistortRectifyMap(this->camera_matrix2,
        this->distance_coefficients2,
        this->R2,
        this->P2,
        this->output_image_size,
        CV_16SC2,
        map21,
        map22);

  // creates rectified images
  remap(left, left_rectified, map11, map12, INTER_LINEAR);
  remap(right, right_rectified, map21, map22, INTER_LINEAR);

  // calculates 16-bit disparitymap
  this->stereo_bm(left_temp, right_temp, disp16);

  disp16.convertTo(disparity_map, CV_8U, 255 / (this->stereo_bm.state->numberOfDisparities * 16.0));
}

This works fine except for a black left border in the disparity map, which is the following:

Disparity map with black border on the left side

The input images are these two - unrectified as you can see ;) : left unrectified image right unrectified image

So my question is now: Is this normal behaviour? Or do you see any mistake i have done so far? As another information, the rectification works fine


Solution

  • The width of the missing region is equivalent to the number of disparities used in stereo_bm. It is a normal by-product of stereo_bm algorithm.