Ask Your Question
3

Big different between StereoSGBM and gpu::StereoBM_GPU

asked 2014-03-03 02:48:28 -0600

thanhit08 gravatar image

updated 2014-03-03 11:47:03 -0600

berak gravatar image

Hello there,

I try to generate disparity of stereo image by using OpenCV and optimize performance by using GPU but the results of them are different.

StereoSGBM initialize

StereoSGBM sbm;
sbm.SADWindowSize = 3;
sbm.numberOfDisparities = 144;
sbm.preFilterCap = 63;
sbm.minDisparity = -39;
sbm.uniquenessRatio = 10;
sbm.speckleWindowSize = 100;
sbm.speckleRange = 32;
sbm.disp12MaxDiff = 1;
sbm.fullDP = false;
sbm.P1 = 216;
sbm.P2 = 864;
sbm(grayLeftCurrentFrameCPU, grayRightCurrentFrameCPU, resultCurrentFrameCPU);
normalize(resultCurrentFrameCPU, resultNorCurrentFrameCPU, 0, 255, CV_MINMAX, CV_8U);

gpu::StereoBM_GPU initialize

gpu::StereoBM_GPU *bm = new gpu::StereoBM_GPU();
bm->preset = gpu::StereoBM_GPU::BASIC_PRESET;
bm->ndisp = 48;
bm->winSize = 5;
bm->operator()(grayLeftCurrentFrameGPU, grayRightCurrentFrameGPU, resultCurrentFrameGPU);
gpu::normalize(resultCurrentFrameGPU, resultNorCurrentFrameGPU, 0, 255, CV_MINMAX, CV_8U);

Anyone know why? Thanks!

(StereoSBM)

StereoSGBM

(gpu::StereoBM_GPU) gpu::StereoBM_GPU

edit retag flag offensive close merge delete

3 answers

Sort by ยป oldest newest most voted
5

answered 2014-03-04 01:51:05 -0600

jensenb gravatar image

The difference in results between the CPU StereoSGBM and the GPU StereoBM_GPU methods does not surprise me. You are mixing up two very different stereo reconstruction approaches. The StereoGM_GPU is (more or the less) equivalent to the StereoBM CPU function, both perform winner takes it all (WTA) stereo matching using sum of absolute differences (SAD) between corresponding left and right image pixel values, such that the disparity with the least cost for each pixel individually is chosen. #

StereoSGBM on the other is a so called semi global method, so that in addition to calculating the least cost (local optimal) disparity value for each pixel individually, it enforces smoothness constraints between neighboring pixels so that they take similar disparity values. In practice such global methods tend to lead to better results, which you have just experienced.

edit flag offensive delete link more
0

answered 2016-09-12 15:43:56 -0600

vishwanathkr gravatar image

A good comparison would be the disparity maps for StereoBM vs CUDA StereoBM. These are the results that I got for the same parameters on these two implementations.

{bm_minDisparity: 0, numDisparities: 32, bm_SADWindowSize: 19, bm_disp12MaxDiff: 48, bm_preFilterCap: 25, bm_textureThreshold: 5, bm_preFilterSize: 5, bm_uniquenessRatio: 5, bm_speckleWindowSize: 25, bm_speckleRange: 10}

It turns out that the disparity maps that they return are of different types CV_16S vs CV_8U respectively. So I'm guessing there is some bit arithmetic wreaking havoc here. Normal StereoBM

CUDA StereoBM

edit flag offensive delete link more
-1

answered 2015-04-29 05:12:44 -0600

This is my stereo match result of BM algorithm between CPU and GPU. Does anyone know why there's hollow inside the object?

image description

CPU

image description

GPU

edit flag offensive delete link more

Comments

This are my prameters,

stereoParamBM:
    pre_filter_size: 63
    pre_filter_cap: 11
    SAD_window_size: 39
    min_disp: 0
    num_of_disp: 80
    texture_thresh: 16
    uniquenese_ratio: 5
    speckle_window_size: 41
    speckle_range: 11
escrowdis gravatar imageescrowdis ( 2015-04-29 05:13:43 -0600 )edit

Hollows are areas where the disparity was not able to be determined. It can be due to lack of distinguishable physical features from which disparity can be calculated, which can also be due to things like a low contrast area, saturated values leading to low contrast, or disparity outside of (min_disparity, min_disparity + num_disparities - 1) range.

opalmirror gravatar imageopalmirror ( 2020-03-05 16:21:00 -0600 )edit
1

Hi @opalmirror, I know there might be insufficient information to determine in the hollows. I think the question I asked is why the outcome from two similar functions has significantly different. But I haven't tested these for a long time. It may enhance to another level. Still thank you for the reply!

escrowdis gravatar imageescrowdis ( 2020-03-07 15:46:48 -0600 )edit

Question Tools

5 followers

Stats

Asked: 2014-03-03 02:48:28 -0600

Seen: 6,536 times

Last updated: Sep 12 '16