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 libnvjpeg.so instead of libjpeg.so.
In CMake I specify libnvjpeg.so for JPEG_LIBRARY, BUILD_JPEG=OFF, WITH_JPEG=ON.
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 libnvjpeg.so to ru with gstreamer nvjpegdec/nvjpegenc and tegra_multimedia_api.
Running with OpenCV is not tested/verified. Other users may share experience.
- Do I understand right that libnvjpeg.so can be used both on Tegra (with Tegra Encoder/Decoder module utilized) and on any CUDA enabled machine (with CUDA utilized)?
- Does libnvjpeg.so depend on libjpeg.so?
- Can I link both libnvjpeg.so and libjpeg.so?
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. libnvjpeg.so is to modify the source code of libjpeg.so 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.
libnvjpeg.so and libjpeg.so has the same func name, my code need both of these, and got corrupted.
I encode fix-sized image (like 1920x1080) with libnvjpeg.so, encode various size image(detected object from previous image) with opencv::imencode, the stack as below:
#0 0x0000000000000000 in ()
#1 0x0000007fb754c850 in jpeg_CreateCompress ()
#2 0x0000007fb7cfb514 in cv::JpegEncoder::write(cv::Mat const&, std::vector<int, std::allocator > const&) () at /usr/local/lib/libopencv_imgcodecs.so.4.0
#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/libopencv_imgcodecs.so.4.0
Please open a new topic for your issue. Thanks