# Is my Disparity Map wrong?

As i'm getting wrong point clouds, i would like to know my disparity map is right...
Below i'm showing the results of the steps from my workflow:

The Rectified Images:  The Disparity Map of the Rectified Images (obtained with numDisparities=24, SADWindowSize=3): The Point Cloud of the Disparity Map (Two different views):  I'm not sure if my Disparity Map looks right...
And the point cloud is obviously wrong... the point cloud is consisting of many "slices"...
Something in the Z-Coordinate is probably wrong?

My disparity map pixel values have the range [0;23]... and there are about ~24 "slices" in the point cloud...

edit retag close merge delete

2

numDisparities=24 <-- means, you get 24 slices, so yes, that's expected.

Oh.. yes you are right.. i didn't think from this point of view..
But why the slides of my point cloud have that strange distance?

1

Q <<   1, 0, 0, -cx,
0, 1, 0, -cy,
0, 0, 0,   f,
0, 0,-1,   0;

Mat_<Vec3f> XYZ(image_disparity.rows, image_disparity.cols);   // Output point cloud
Mat_<float> vec_tmp(4, 1);

for (int y = 0; y < image_disparity.rows; ++y) {
for (int x = 0; x < image_disparity.cols; ++x) {
vec_tmp(0) = x;
vec_tmp(1) = y;
vec_tmp(2) = image_disparity.at<float>(y, x);
vec_tmp(3) = 1;

vec_tmp = Q * vec_tmp;

Vec3f &point = XYZ.at<Vec3f>(y, x);
point = vec_tmp(0);
point = vec_tmp(1);
point = vec_tmp(2)/vec_tmp(3);
}
}

2

^^ ah, cool. now at least, we've got something, we can send "the next one" to ;)

but honestly, 3d from disparity is hard , even with a proper calibrated stereo rig (which you don't have).

and yea, your disparity looks like sh..t (it's not a problem with the viewer, or with your projection formula)

1

keep on experimenting, but rather try to simulate, what a stereo cam (or 2 human eyes) would see.

e.g. i think, your images are "too far apart", and the direction is not "parallel" enough (don't start me on the cars ...)

for comparison, here's a "nice" disparity image