OpenCV with libnvjpeg

I want to utilize NVIDIA nvjpeg library for fast JPEG (de)compression on NVIDIA Jetson.
For this I build OpenCV from sources and point it to instead of
Though OpenCV builds successfully, I get an unspecified error while trying to call imread on jpg image.
If, additionally, I point JPEG_INCLUDE_DIR to ~/tegra_multimedia_api/include/libjpeg-8b it builds ok too, but then I get another error while trying to call imread on jpg image.
Any ideas how to solve this?

We only support to ru with gstreamer nvjpegdec/nvjpegenc and tegra_multimedia_api.

Running with OpenCV is not tested/verified. Other users may share experience.

Thanks. Also

  1. Do I understand right that can be used both on Tegra (with Tegra Encoder/Decoder module utilized) and on any CUDA enabled machine (with CUDA utilized)?
  2. Does depend on
  3. Can I link both and

To be more clear.
I want to use libnvjpeg in ROS compressed_image_transport plugin (shared library) instead of standard libjpeg. This means that my plugin will be loaded by other ROS plugins\packages, which
are often linked against libjpeg, either directly or through OpenCV, etc.
Hence, both libjpeg and libnvjpeg are loaded and all joint symbols are bound to libjpeg
during dynamic library loading.
Hence, I have incompatibility problems calling jpeg functions in compressed_image_transport plugin.

So, I cannot use libnvjpeg anywhere except simple standalone programs like samples from Tegra MMAPI`.

One way to overcome this I see is to link compressed_image_transport plugin against static version of libnvjpeg. Can you provide libnvjpeg.a?

No. It only runs on TX1/TX2. There is JPG HW component in TX1/TX2. It is not a CUDA implementation.

No. is to modify the source code of to have HW acceleration.

I think no. The function names are the same and it may trigger double definitions.

We suggest users use NvJpegEncoder and NvJpegDecoder classes.

I do use NvJpegEncoder and NvJpegDecoder classes. But it doesn’t save me from double definition when being used with other software (ROS, etc).
So, is static version of libnvjpeg available?


No, it is dynamic library in each release. and has the same func name, my code need both of these, and got corrupted.
I encode fix-sized image (like 1920x1080) with, encode various size image(detected object from previous image) with opencv::imencode, the stack as below:
#0 0x0000000000000000 in ()
#1 0x0000007fb754c850 in jpeg_CreateCompress ()
at /usr/lib/aarch64-linux-gnu/tegra/
#2 0x0000007fb7cfb514 in cv::JpegEncoder::write(cv::Mat const&, std::vector<int, std::allocator > const&) () at /usr/local/lib/
#3 0x0000007fb7cf0274 in cv::imwrite(std::__cxx11::basic_string<char, std::char_traits, std::allocator > const&, cv::_InputArray const&, std::vector<int, std::allocator > const&) () at /usr/local/lib/

Please open a new topic for your issue. Thanks