c++ - Black columns in the disparity map when using StereoBM -


i trying use stereobm in opencv extract disparity map pair of images. ignoring bad quality of disparity map below, can see has number of black columns on left correspond parameter ndisparities. thought ndisparities tells stereobm how "far" away can search correspondence. cause behaviour? seems limit width of resulting depth map, don't see why.

disparity map

you can see stereo pair here , code below. in advance pointers!

mat limg = imread("left.jpg", cv_load_image_grayscale); mat rimg = imread("right.jpg", cv_load_image_grayscale);  mat disp(limg.size(), cv_16sc1), disp8u; int ndisparities = 512; stereobm sbm(stereobm::basic_preset, ndisparities , 11); sbm(limg, rimg, disp, cv_16s);  double minval, maxval; minmaxloc( disp, &minval, &maxval ); disp.convertto( disp8u, cv_8uc1, 255/(maxval - minval)); imshow("disparity", disp8u) 

the disparity map quantifies longitudinal (epipolar) offset between corresponding pairs of points in left , right image.

in principle,

 disparity := x_l - x_r 

where x_l , x_r projections on focal plane of 2 cameras of given point in space. (keep in mind large disparities characterize pixels closer cameras. [a])


the parameter ndisparities quantifies expected maximum disparity can have (assuming can neglect min disparity).

since assuming ndisparities largest disparity, holds true

    x_l - x_r < ndisparities, 

i.e.

    x_r > x_l - ndisparities  

therefore, makes no sense looking correspondences right image of pixel in first ndisparities columns of left image: can't have.

in sense, view cone of right camera starts ndisparities columns on right of view cone of left camera.


a fix:

if want less black columns on left hand side of disparity map, need able assume lower values of ndisparities.

since ndisparities depends on distance cameras of closest object (from [a]), either put cameras further away object or put cameras closer 1 another.

in specific case have huge disparity (a lot of work stereobm)!! 'x' symbol in foreground shows disparity comparable scale of image!! believe need put cameras further away.


Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -