How to increase the quality of Disparity Map?
I am working on stereo images. After doing camera calibration and everything, I am trying to get a depth image. But depth image depends on the disparity map and I am not getting proper disparity map.
Here is a screenshot of my Disparity Map. (It shows only one image, but I have two images from two diff webcams separated by around 3cms)
I am using StereoBM
and following are the values that I have set.
StereoBM sbm;
sbm.state->SADWindowSize = 25;
sbm.state->numberOfDisparities = 64;
sbm.state->preFilterSize = 27;
sbm.state->preFilterCap = 63;
sbm.state->minDisparity = 0;
sbm.state->textureThreshold = 20;
sbm.state->uniquenessRatio = 9;
sbm.state->speckleWindowSize = 0;
sbm.state->speckleRange = 4;
I want Disparity Map generation to be real time. Graph Cut algorithm seems to take a lot of time. Is there any method by which I can increase the quality of Disparity Map?
Martin Peris has a neat tool to adjust the states for the block method: http://blog.martinperis.com/2011/08/opencv-stereo-matching.html
Actually, I have used that program to get these values. But can't figure out how to get better quality.
As a guess, I would use a lower window size and fewer disparities. The larger the window size, the fewer fine details. I use 5 to keep the processor time to a minimum and 7 looks a little better, but after that, it looks worse. The algorithm doesn't seem to work well if the number of disparities gets too high, in some cases.It will work better if you set the minimum number of disparities near the disparity at the range of your closest subject (it will be non-zero). There is a simple formula out there to calculate the disparity, but most authors want to get too esoteric. Solving this guy's range equation for disparity will work. https://code.google.com/p/sentience/wiki/StereoRanging
I think that the texture threshold looks too high. I will give you my numbers when I get to the office.
@jayrambhia, did you end up finding a way to get better quality out of the disparity map?
yeah. I have added those parameters here. http://jayrambhia.com/blog/disparity-maps/