Ask Your Question
0

missing region in disparity map

asked 2012-09-17 07:45:58 -0600

m47h gravatar image

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:

image description

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

image description image description

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.

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
1

answered 2012-09-18 02:54:58 -0600

Jacek gravatar image

I think it's a normal behaviour that region with x-coordinates between 0 and max_disparity is not reconstructed.

Suppose on a rectified left image you have a point with x-coordinate x0, where 0 < x0 < max_disparity. Potential matches for this point on the right rectified image have x-coordinate in < x0-max_disparity; x0 > range. But if x0 < max_disparity part of this range has negative x-coordinate and is not visible on the rectified right image. So disparity cannot be calculated.

And one advice: for better results use StereoSGBM algorithm. It usually gives much better results than simple block matching (StereoBM) algorithm.

edit flag offensive delete link more

Comments

Is there any way to solve this problem using the StereoBM Algorithm

KarimO gravatar imageKarimO ( 2014-03-14 08:57:24 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2012-09-17 07:45:58 -0600

Seen: 1,485 times

Last updated: Sep 18 '12