Is my Disparity Map wrong?

asked 2017-03-09 06:21:41 -0600

mirnyy gravatar image

updated 2017-03-09 07:40:07 -0600

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:
Rectified image left Rectified image right

The Disparity Map of the Rectified Images (obtained with numDisparities=24, SADWindowSize=3):
Disparity Map of the Rectified images

The Point Cloud of the Disparity Map (Two different views):
Point Cloud of the Disparity Map (View 1) Point Cloud of the Disparity Map (View 2)

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

Comments

2

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

berak gravatar imageberak ( 2017-03-09 07:46:08 -0600 )edit

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?

mirnyy gravatar imagemirnyy ( 2017-03-09 07:51:59 -0600 )edit

btw, above is without Q, right ?

berak gravatar imageberak ( 2017-03-09 08:06:22 -0600 )edit
1

It is... i made:

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[0] = vec_tmp(0);
        point[1] = vec_tmp(1);
        point[2] = vec_tmp(2)/vec_tmp(3);
    }
}
mirnyy gravatar imagemirnyy ( 2017-03-09 08:11:41 -0600 )edit
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)

berak gravatar imageberak ( 2017-03-09 10:38:44 -0600 )edit
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 ...)

berak gravatar imageberak ( 2017-03-09 10:51:56 -0600 )edit

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

may i ask, what your "use-case" is ?

for certain situations (small things, indoor) there are alternatives to block-matching (photogrammetric stereo, structured light, etc)

berak gravatar imageberak ( 2017-03-09 11:11:00 -0600 )edit

it should be used for an application similar to Google Streetview... so outdoor usage

mirnyy gravatar imagemirnyy ( 2017-03-09 11:58:47 -0600 )edit