c++ - OpenCv depth estimation from Disparity map -
i'm trying estimate depth stereo pair images opencv. have disparity map , depth estimation can obtained as:
(baseline*focal) depth = ------------------ (disparity*sensorsize)
i have used block matching technique find same points in 2 rectificated images. opencv permits set block matching parameter, example bmstate->numberofdisparities
.
after block matching process:
cvfindstereocorrespondencebm( frame1r, frame2r, disp, bmstate); cvconvertscale( disp, disp, 16, 0 ); cvnormalize( disp, vdisp, 0, 255, cv_minmax );
i found depth value as:
if(cvget2d(vdisp,y,x).val[0]>0) { depth =((baseline*focal)/(((cvget2d(vdisp,y,x).val[0])*sensor_element_size))); }
but depth value obtaied different value obtaied previous formula due value of bmstate->numberofdisparities
changes result value.
how can set parameter? change parameter?
thanks
the simple formula valid if , if motion left camera right 1 pure translation (in particular, parallel horizontal image axis).
in practice hardly ever case. common, example, perform matching after rectifying images, i.e. after warping them using known fundamental matrix, corresponding pixels constrained belong same row. once have matches on rectified images, can remap them onto original images using inverse of rectifying warp, , triangulate 3d space reconstruct scene. opencv has routine that: reprojectimageto3d
Comments
Post a Comment