Ask Your Question
0

[Python]Stereo disparity quality problems

asked 2018-01-09 15:06:16 -0600

Ahapid gravatar image

Disclaimer: i am a beginner. I edited the example python stereo_match.py code a bit to get "live" feed from my 2 webcams. I calibrated them about right, the Y offset is right but i have not set the distortion offset yet. I played around a bit with the values but couldn't get it perfect. stereoImage https://imgur.com/a/RfH5p code https://pastebin.com/gfffQMq4

so my questions are: what is each value for? (i.e. num disparites) why is my depth map so 'fuzzy' in the background? and while i am at it, what causes the black bar?

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
2

answered 2018-01-31 14:49:09 -0600

updated 2018-01-31 16:33:59 -0600

The C++ documentation helps some... see cv::StereoSGBM Class Reference. My takes on it follow.

StereoMatching parameters:

  • minDisparity is the smallest disparity value to search for. Use smaller values to look for scenes which include objects at infinity, and larger values for scenes near the cameras. Negative minDisparity can be useful if the cameras are intentionally cross-eyed, but you wish to calculate long-range distances. Setting this to a sensible value reduces interference from out of scene areas and reduces unneeded computation.

  • numDisparities is the range of disparities to search over. It is effectively your scene's depth of field setting. Use smaller values for relatively shallow depth of field scenes, and large values for deep depth-of-field scenes. Setting this to a sensible value reduces interference from out of scene areas and reduces unneeded computation.

  • blockSize is the dimension (in pixels on a side) of the block which is compared between the left and right images. Setting this to a sensible value reduces interference from out of scene areas and reduces unneeded computation.

  • disp12MaxDiff, speckleRange, speckleWindowSize - used in filtering the disparity map before returning, looking for areas of similar disparity (small areas will be assumed to be noise and marked as having invalid depth information). These reduces noise in disparity map output.

StereoBM:

  • preFilterCap, preFilterSize, preFilterType - used in filtering the input images before disparity computation. These may improve noise rejection in input images.

  • ROI1, ROI2 - region of interest, used to constrain the computation to a smaller rectangle within the input images. These may help avoid unneeded computation.

  • textureThreshold, uniquenessRation, smallerBlockSize - used in filtering the disparity map before returning. May reduce noise.

StereoSGBM:

  • mode - selects the block compare mechanism to use. Some modes may perform much better for certain input scenes, comparing a few lines out of the entire block rather than every pixel in the block.

  • P1, P2, uniquenessRation - used in filtering the disparity map before returning to reject small blocks. May reduce noise.

  • preFilterCap - used in filtering the input images before disparity computation. These may improve noise rejection in input images.

Fuzziness can be due to:

  • poor calibration or rectification - calibration (discovery of distortion, rotation, translation matrices) must be very accurate, to within a fraction of a pixel correspondence between left and right, in order to rectify the left and right images to epipolar form so that the disparity algorithms will return accurate results.

  • poor contrast/illumination or poor focus resulting in mismatches - features in left and right cameras must be clear and not under or over exposed.

  • too regular a background pattern (mismatches) or no background pattern (hard to get a valid distance) - random pattern projectors can help here.

  • poor range selection: minDisparities and numDisparities are not set to select just the range of interesting disparities for your scene, causing interfering matches from depths outside your range of interest - constrain these as sensible.

  • filtering of input images or output disparity map can reduce noise blobs.

The black bar is the sum of:

  • blockSize / 2 (which makes a frame around ...

(more)
edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2018-01-09 15:06:16 -0600

Seen: 5,303 times

Last updated: Jan 31 '18