jpeg_CreateCompress () from /usr/lib/aarch64-linux-gnu/tegra/libnvjpeg.so JetPack 4.2.1 on jetson-x...

I use Ros melodic on xavier.When I use cv_bridge::CvImage to change cv::Mat to CompressedImage,it says "
[New Thread 0x7fa1ffa740 (LWP 3110)]
[New Thread 0x7fa1bf9740 (LWP 3111)]
[New Thread 0x7fa17f8740 (LWP 3112)]
[New Thread 0x7fa13f7740 (LWP 3113)]
[New Thread 0x7fa0ff6740 (LWP 3114)]
[New Thread 0x7fa0bf5740 (LWP 3115)]
[New Thread 0x7fa07f4740 (LWP 3116)]

Thread 7 “DecCapPlane” received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7fa8d3d740 (LWP 3104)]
0x0000007fb7c18968 in jpeg_CreateCompress () from /usr/lib/aarch64-linux-gnu/tegra/libnvjpeg.so
"
My code is as bellow:
void onGetYuvData(const char * pData,unsigned long dataSize){
ROS_INFO(“onGetYuv %ld”,dataSize);
if(ros::ok()){
Mat yuvImage;
yuvImage.create(720*3/2,1280,CV_8UC1);
memcpy(yuvImage.data,pData,dataSize);

        cv::Mat image;
        cvtColor(yuvImage,image,CV_YUV420p2RGB);
       
        

       sensor_msgs::CompressedImagePtr msg = cv_bridge::CvImage(std_msgs::Header(), "bgr8", image).toCompressedImageMsg();
        msg->header.seq = seq++;
        msg->header.stamp = ros::Time::now();

        imagePublisher.publish(msg);
        
        ros::spinOnce();
        rate->sleep();

    }
}

collpym,

Sorry that I am not working on ros. Does this issue only happen on tegra (libnvjpeg)?

Hi,
It might be an issue in referring to wrong header files. Please check if it refers to

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

while building the application.

Or you may try to use default libjpeg.so

Thanks for reply.
I try to change my header files to “/usr/src/tegra_multimedia_api/include/libjpeg-8b”,the problem still exists.
I’m using L4T Multimedia API to get Hardware Accelerate.
“cv_bridge::CvImage(std_msgs::Header(), “bgr8”, image).toCompressedImageMsg()” use opencv to process the jpeg to compressed jpeg.OpenCv will find the encoder to do the job.In my situation,I think opencv use jpeg encoder from libnvjpeg.

I try to remove libnvjpeg,It works OK.I’m not sure if I remove libnvjpeg whether can I get hardware accelate.

Hi,
In default release, we don’t support libnvjpeg working with OpenCV APIs. You may try to work out a solution. Other users may also share their experiences.

For using hardware JPEG decoding, please consider to use tegra_multimedia_api.