# 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:

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

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 close merge delete

Sort by ยป oldest newest most voted

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.

more

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

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

Official site

GitHub

Wiki

Documentation