jpeg encode and openCV conflict ?

Hi,

I have used opencv imwrite and used multimedia API jpeg encode, but the application will breakdown in imwrite. When I use jpeg encode library. When I delete the jpeg encode, the imwrite will not problem.

Thanks.

Hi,

this is my add

INCLUDEPATH +=/home/nvidia/tegra_multimedia_api/include \
              /home/nvidia/tegra_multimedia_api/argus/samples/utils
    LIBS += /home/nvidia/tegra_multimedia_api/samples/common/classes/NvElementProfiler.o
    LIBS += /home/nvidia/tegra_multimedia_api/samples/common/classes/NvElement.o
    LIBS += /home/nvidia/tegra_multimedia_api/samples/common/classes/NvApplicationProfiler.o
    LIBS += /home/nvidia/tegra_multimedia_api/samples/common/classes/NvVideoDecoder.o
    LIBS += /home/nvidia/tegra_multimedia_api/samples/common/classes/NvBuffer.o
    LIBS += /home/nvidia/tegra_multimedia_api/samples/common/classes/NvJpegEncoder.o
    LIBS += /home/nvidia/tegra_multimedia_api/samples/common/classes/NvVideoConverter.o
    LIBS += /home/nvidia/tegra_multimedia_api/samples/common/classes/NvDrmRenderer.o
    LIBS += /home/nvidia/tegra_multimedia_api/samples/common/classes/NvLogging.o
    LIBS += /home/nvidia/tegra_multimedia_api/samples/common/classes/NvEglRenderer.o
    LIBS += /home/nvidia/tegra_multimedia_api/samples/common/classes/NvUtils.o
    LIBS += /home/nvidia/tegra_multimedia_api/samples/common/classes/NvJpegDecoder.o
    LIBS += /home/nvidia/tegra_multimedia_api/samples/common/classes/NvVideoEncoder.o
    LIBS += /home/nvidia/tegra_multimedia_api/samples/common/classes/NvV4l2ElementPlane.o
    LIBS += /home/nvidia/tegra_multimedia_api/samples/common/classes/NvV4l2Element.o
    LIBS += /home/nvidia/tegra_multimedia_api/samples/common/algorithm/cuda/NvAnalysis.o
    LIBS += /home/nvidia/tegra_multimedia_api/samples/common/algorithm/cuda/NvCudaProc.o
    LIBS += -I"/usr/include/aarch64-linux-gnu" -I"/home/nvidia/tegra_multimedia_api/include"
    LIBS += -I"/home/nvidia/tegra_multimedia_api/include/libjpeg-8b" -I"/usr/include/libdrm"
    LIBS += -I"/home/nvidia/tegra_multimedia_api/samples/common/algorithm/cuda"
    LIBS += -L"/usr/lib/aarch64-linux-gnu" -L"/usr/lib/aarch64-linux-gnu/tegra"
    LIBS += -lpthread -lv4l2 -lEGL -lGLESv2 -lX11 -lnvbuf_utils -lnvjpeg -lnvosd -ldrm
    LIBS += /home/nvidia/NVIDIA_CUDA-8.0_Samples/common/lib/linux/aarch64/libGLEW.a

and the test demo, when I don’t add library, the demo can exec, but when I add the library, it will breakdown in imwrite.

int main()
{
    Mat src;

    src = imread("test.jpg");

    imwrite("22.jpg", src);
    waitKey(0);
}

Seems that there is library conflict. Could you directly use our sample to do Jpeg encode/decode instead of openCV?

Hi,

we have to use double of them, so how can we solve this conflict ?

Instead of using imread, imwrite, could you try to use our MMAPI sample?
00_video_decode
01_video_encode

Hi,

above samples seem like to encode or decode video data. But what I really want it to save the image to the file: 1. save the source image to file. 2.crop face boxes from source image and save to file. First, We all use opencv imwrite. But it was so slow when saved source image, so we change to use jpegEncoder like MMAPI sample 9. It was faster than imwrite. Then we found the library would conflict when both use MMAPI encode and opencv imwrite. So we change the way to save face image also use MMAPI encode instead of opencv imwrite. But there will happen problem like the link:https://devtalk.nvidia.com/default/topic/1029239/does-the-jpegencoder-not-clear-the-buffer-/#5235716

It should run well with pixel alignment.
https://devtalk.nvidia.com/default/topic/1029239/jetson-tx2/does-the-jpegencoder-not-clear-the-buffer-/post/5235949/#5235949

Hi,
I have exprienced same problem.
Is this problem solved ?

Structure size between OpenCV and nvjpeg seems not same and cannot avoid conflicting.
Error message shows
JPEG parameter struct mismatch: library thinks size is 584, caller expects 712
I tried also usin gstreamer nvjpegenc and imread but same problem occur.
I tried to hide symbol by -fvisibility=hidden but did not work well.
How can I use both OpenCV imread and nvjpeg encoder ?

When I tired nvjpeg for decoding it crashed with one of jpeg picture
https://devtalk.nvidia.com/default/topic/1043325/nvjpeg-die-on-decoding-picture/
So I cannot use nvjpeg for decoding.