Nvjpeg Cmake and OpenCV frames

Hello, I would like to know if someone managed to build a C++ project that uses NvJpegEncoder and NvJpegDecoder classes or other Jetson Multimedia API functions with cmake.

I was trying to do the OpenCV’s Videowriter with nvjpeg and the LD_PRELOAD=/usr/lib/aarch64-linux-gnu/tegra/libnvjpeg.so trick worked for me but it breaks some functions like imdecoder or imwrite. I am still undecided how to implement it. As far as I know there is the gstreamer or the Multimedia API way but I didn’t find any successful story and any insights on this would be welcomed.

Thanks in advance.

You may try:

Yes, that worked. However, I was wondering if that could be added on Cmake somehow without fiddling with the .bashrc file and potentially breaking something. If not, I was considering learning the Gstreamer API.

For a single use case I’d advise to just use a shell alias that wouldn’t mess with anything else than your application:

alias your_app='LD_PRELOAD=/usr/lib/aarch64-linux-gnu/tegra/libnvjpeg.so  /absolute/path/to/your_app'

For a more generic case, may be you may try rt-link paths for cmake install, but I can’t help for this.
Please share if you succeed, this may be helpful.

Also be aware that using opencv for other backends using jpeg than NVIDIA may no longer work, as there is a discrepancy with jpeg struct with nvidia lib’s as compared to standard jpeg lib.