ORB-SLAM2-GPU2016-final icon indicating copy to clipboard operation
ORB-SLAM2-GPU2016-final copied to clipboard

Core dump on Stereo mode

Open toniomtb opened this issue 6 years ago • 4 comments

Hi, i've tested the SLAM on GPU in monocular mode and it works very well, but i've found an error in stereo mode. In file Frame.cc, from line 567 to 571 the code is:

`const int w = 5;

cv::cuda::GpuMat gMat = mpORBextractorLeft->mvImagePyramid[kpL.octave].rowRange(scaledvL - w, scaledvL + w + 1).colRange(scaleduL - w, scaleduL + w + 1);

cv::Mat IL(gMat.rows, gMat.cols, gMat.type(), gMat.data, gMat.step);

IL.convertTo(IL,CV_32F);

IL = IL - IL.at(w,w) *cv::Mat::ones(IL.rows,IL.cols,CV_32F);`

The problem is: the cv::Mat IL is pointing to some address in the gpu, but IL is on the host memory, and it's not possible to reference something in the gpu, this is causing the slam to crash in stereo mode. Same thing happen in lines 586 to 589.

i'm asking for help since i've not yet found a way to fix this problem. i've tried to download the gMat to the host memory with the cv::cuda::GpuMat::download() function but it's slowing down too much the algorithm, since it makes constant memory transfer from gpu to host. I think that a fix can be to execute all the following operation in gpu and not on cpu.

Thanks for the attention, Antonio

toniomtb avatar Apr 27 '18 08:04 toniomtb

Executing following operations on GPU is viable. Do you have a patch?

yunchih avatar Apr 27 '18 14:04 yunchih

No, i'm trying to fix this problem but since now i've not found any solution, since i'm not familiar with cuda programming.

toniomtb avatar Apr 27 '18 15:04 toniomtb

Sorry that I can't roll out a patch for you, either, as I am busy working on other projects. But should anyone also encounter this problem, I'd be appreciative for any patch.

Thanks for reaching.

yunchih avatar Apr 28 '18 13:04 yunchih

I clocked the time of the Frame::ComputeStereoMatches() function, which looks like the bottleneck here. Because the Mat is being downloaded from the mvImagePyramid GpuMat within the for loop, it takes more than 2 seconds to process this function for each frame. I am trying to execute the following operations using the GPU and just return the norm between the left and right images to the CPU. Has anyone written a custom cuda kernel to perform this task?

connorsoohoo avatar Aug 10 '18 20:08 connorsoohoo