opencv_contrib icon indicating copy to clipboard operation
opencv_contrib copied to clipboard

Colored_kinfu too slow when running upate method

Open carlos-martinez opened this issue 4 years ago • 1 comments

System information (version)
  • OpenCV => 4.5.3
  • Operating System / Platform => Windows 64 Bit
  • Compiler => Visual Studio 2019
Detailed description

Hi, I am trying to get a sense of how the colored_kinfu class works, so I started by using the sample project colorized_kinfu_demo with an Intel D455 camera. I modified the code in order to have a single rs2::pipeline for both depth and rgb “grabbers”.

The code is able to get both images, but it takes too much time (around 13 seconds) to execute the update method. I already checked and that it the flag to use GPU is enabled ( cv::setUseOptimized(true));

image

As a comparison, I ran the other kinfu_demo (no color), and the speed performance seems comparable to the previous kinfu version in OpenCV 4.2.0.

Any ideas or guidance of something I might be doing wrong.

Thanks

carlos-martinez avatar Oct 15 '21 21:10 carlos-martinez

Code

Looking at code at OpenCV contrib/rgbd 4.x ColoredKinfu doesn't seem to have GPU implementation:

https://github.com/opencv/opencv_contrib/blob/e72e1715771de730c6229aaa6b848efa0d54def9/modules/rgbd/src/colored_kinfu.cpp#L370

Compare with Kinfu implementation: https://github.com/opencv/opencv_contrib/blob/e72e1715771de730c6229aaa6b848efa0d54def9/modules/rgbd/src/kinfu.cpp#L333

The difference is with Mat/UMat in Kinfu and Mat only in ColoredKinfu

The same can be said about its building block ColoredTSDF (explicitly creates CPU implementation): https://github.com/opencv/opencv_contrib/blob/e72e1715771de730c6229aaa6b848efa0d54def9/modules/rgbd/src/colored_tsdf.cpp#L1034

Documentation

The ColoredKinFu documentation is misleading, probably copied from KinFu: https://docs.opencv.org/4.x/d5/d61/classcv_1_1colored__kinfu_1_1ColoredKinFu.html

Stating that:

KinFu uses OpenCL acceleration automatically if available. To enable or disable it explicitly use cv::setUseOptimized() or cv::ocl::setUseOpenCL().

Other Variants

Looking at code it seems that only KinFu and LargeKinFu have GPU implementation at this time.

The KinFu is functional, I am not sure about the other one.

bmegli avatar May 26 '22 13:05 bmegli