Graphical Unit Processors (GPU) excels in operations related to image processing. Most of the time, they offer significant benefits in terms of performance over a Central Processing Units (CPU).
Since the onboard computer of the AUV is a Jetson AGX Xavier equipped with a relatively powerfull NVIDIA GPU compared to it's CPU, it would be a shame not to use it! Following this idea, one of the main goal of the proc_image_processing refactoring project is to make use of the NVIDIA GPU API named CUDA which would allow better performance in order to apply different filters on the images received from the cameras of the AUV. Lucky for us, OpenCV has features built-in to take advantages of GPU processing.
We got you covered!
The proc_image_processing module now has a feature that allows it to run in a CPU mode or in a GPU mode.
But wait, there is more!
When building the module, it automatically detects which mode to use:
In other words, the module is retrocompatible with hardware that don't have any NVIDIA GPU.
Of course, if a developper's computer isn't equiped with a compatible NVIDIA GPU, he won't be able to use the GPU mode. Knowing this, it was necessary to maintain a CPU implementation.
Please take note that no features have been implemented with the GPU yet, since it means a complete redesign of the project.
Since most modules of the AUV have an already present Docker architecture, some modifications had to be done in order to use CUDA. As such, proc_image_processing needed to use a Docker image with CUDA, OpenCV and ROS built-in. In order to do that, multiple images have been built so that it follows this hierarchy:
The main reason behing this hierarchy is to avoid needing to compile OpenCV (which is lengthy and fastidious) everytime a new feature is added or a new change introduced into main or develop. Since OpenCV is precompiled on an existing image, it is possible to avoid compiling.
As you can see in the diagrams, the base Docker image for OpenCV with CUDA is built on an external repository. This is mainly due to the current Docker architecture that doesn't allow us to benifit from layer caching, which essentially allows us to skip steps in our Dockerfile if a change does not need to modify certain layers. In other words, once OpenCV is compiled with CUDA, we don't need to compile it each time we commit something on the repository, it'll just reuse what hasn't changed or been impacted by the commit.
We implemented several benchmarking tools in order to test various methods that can be used with OpenCV CUDA. Since it is very subjective and varies from a computer to another, we don't have exact numbers regarding the actual gains in performance.
From what we could extract using these tools: