I want to get real distance of an object from stereo camera. I am using OpenCV example code as given in Learning OpenCV O'Reilly book. After getting disparity map I want to use the formula:
distance = focal_length * baseline distance / disparity
The problem is :
I am getting negative values of disparities. How to convert these values so that they might be used in actual depth calculation ?
In above formula focal length and baseline distance are in mm (returned by reprojection matrix) whereas disparity will be in pixels. So the result will be in mm^2/pixel. How to convert disparity value from pixel to mm.