Attempting to stream camera video and encode with nvjpeg, but lib mismatch? (C++)

Hi,

I am taking the source from https://github.com/JetsonHacksNano/CSI-Camera and changing “videoconvert” to “nvjpegenc”. I can compiling successfully with this command:

g++ simple_camera.cpp -o simple_camera `pkg-config --cflags --libs opencv`

However, I get this result:

JPEG parameter struct mismatch: library thinks size is 584, caller expects 728

I found this thread: https://devtalk.nvidia.com/default/topic/1057461/jetson-nano/jetson-nano-gstreamer-opencv-using-nvjpegenc-to-encode-frames-from-opencv-as-appsrc/post/5362215/#5362215

which leads me to believe I am not linking against the nvjpeg lib, but I am unsure how to do that. I’ve tried the following with no luck:

g++ simple_camera.cpp -o simple_camera `pkg-config --cflags --libs opencv` -L/usr/src/nvidia/tegra_multimedia_api/include/libjpeg-8b -lnvjpeg

The result for the above command is:

/user/bin/ld: cannot find -lnvjpeg

Any ideas?

The path for link looks wrong. Try instead

-L/usr/lib/aarch64-linux-gnu/tegra

Thanks! That gets rid of any of the linking problem, but I am still getting the JPEG parameter struct mismatch error.

this is my build command:

g++ simple_camera.cpp -o simple_camera `pkg-config --cflags --libs opencv` -L/usr/lib/aarch64-linux-gnu/tegra -lnvjpeg

and this is the result:

Using pipeline:
	nvarguscamerasrc ! video/x-raw(memory:NVMM), width=(int)3264, height=(int)2464, framerate=(fraction)12/1, format=(string)NV12 ! nvvidconv ! video/x-raw, width=(int)3264, height=(int)2464 ! nvjpegenc ! appsink
JPEG parameter struct mismatch: library thinks size is 584, caller expects 728

Hi,
For running with OpenCV, we suggest use jpegenc instead of nvjpegenc. OpenCV links to libjpeg.so in many places and it is difficult to replace it with libnvjpeg.so.

Ah, that make sense. How difficult are we talking? We are looking at the nvjpegenc due to performance reasons

Hi,
We are not not sure about the effort. Have not seen users successfully done this and shared the result( also possible some users have done it but do not share ).

please add this include directory

-I/usr/src/nvidia/tegra_multimedia_api/include/libjpeg-8b

example gcc -o jpeg_enc jpeg_enc.c -I/usr/src/nvidia/tegra_multimedia_api/include/libjpeg-8b -L/usr/lib/aarch64-linux-gnu/tegra -lnvjpeg -w -Wall

https://gist.github.com/jocover/c387640030f67ad33293d3d751f15fa6

1 Like