Ask Your Question
2

CUDA StereoBM setMinDisparity-Function

asked 2017-03-08 08:22:45 -0600

mirnyy gravatar image

updated 2017-03-08 08:27:38 -0600

Hello,

is it possible to change the minDisparity-Parameter in the cuda::StereoBM function like in cv::StereoBM?
I would like to change that Parameter with a trackbar, but it's not working.

My minimal snippet:

void onTrackbar(int nothing, void* data){
  cuda_sbm->setMinDisparity(minDisparity);
  cuda_sbm->setNumDisparities(ndisparities);
  cuda_sbm->setBlockSize(SADWindowSize);
}


//global
int minDisparity, ndisparities, SADWindowSize;
Ptr<cuda::StereoBM> cuda_sbm = cuda::createStereoBM(ndisparities, SADWindowSize);

//inside main
cuda_sbm->compute(image1_rectified_grayGPU, image2_rectified_grayGPU, image_disparityGPU);
....

createTrackbar("minDisparity", "Disparitaet", &minDisparity, 50, onTrackbar);
createTrackbar("ndisparities", "Disparitaet", &ndisparities, 100, onTrackbar);
createTrackbar("SADWindowSize", "Disparitaet", &SADWindowSize, 31, onTrackbar);

It is working with the cuda_sbm->setNumDisparities(ndisparities)
and cuda_sbm->setBlockSize(SADWindowSize) functions perfectly,
but it doesn't work with cuda_sbm->setMinDisparity(minDisparity)

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
1

answered 2017-09-29 14:54:36 -0600

Looking at the code, it appears the CUDA implementation only supports a default minimum disparity setting, 0.

Any value passed to the setMinDisparity function is not honored (discarded). See modules/cudastereo/src/stereobm.cpp:

void setMinDisparity(int /*minDisparity*/) {}
edit flag offensive delete link more

Comments

1

@mirnyy did this help at all? if not, what else can I do to improve the answer? Thanks!

opalmirror gravatar imageopalmirror ( 2017-11-14 15:22:50 -0600 )edit
1

Hello, it helped me (at least now i know that the function doesn't use the "minDisparity" value), but i still need to use that function with a negative dispartiy.

mirnyy gravatar imagemirnyy ( 2017-11-15 08:31:45 -0600 )edit

I presume you are using a different stereo disparity implementation which can handle negative minDisparities, like cv::StereoBM, but wish you had the performance of cuda::StereoBM. Some more ideas off the top of my head:

1) Physical change: Are the cameras converging/diverging rather than parallel? If so, can their pointing be changed to be parallel and then recalibrated to allow minDisparities == 0 to mean max distance of interest?

2) Try translating (moving pixels) in the right image by amount of the negative offset (I'm thinking these would move right). That might allow you to do the stereo matching with minDisparity=0 using CUDA, then you'd need to interpret the actual depth differently from the resulting disparity array.

I hope one of these work out for you.

opalmirror gravatar imageopalmirror ( 2017-11-15 15:02:27 -0600 )edit

Question Tools

2 followers

Stats

Asked: 2017-03-08 08:22:45 -0600

Seen: 1,457 times

Last updated: Sep 29 '17