Error generated. main.cpp, threadExecute:152 Failed to copy frame to NvBuffer

I’m testing the Argus sample code installed with jetpack (currently jp 4.3) with a MIPI camera provided by our vendors. Image reading seems fine but when I’m testing one example, after a period of running, the code starts to raise error.

Specifically, I’m testing

/usr/src/jetson_multimedia_api/samples/09_camera_jpeg_capture/

This is the command I’m using

./camera_jpeg_capture  --cap-time=15 -s --fps=60 

The error is like this:

Save frame id 763
Save frame id 764
Save frame id 765
Save frame id 766
Save frame id 767
Save frame id 768
Save frame id 769
Save frame id 770
Save frame id 771
Save frame id 772
Save frame id 773
Save frame id 774
Save frame id 775
(Argus) Error BadParameter:  (propagating from src/eglstream/ImageImpl.cpp, function initialize(), line 382)
(Argus) Error BadParameter:  (propagating from src/eglstream/ImageImpl.cpp, function copyToNvBuffer(), line 440)
(Argus) Error BadParameter:  (propagating from src/eglstream/ImageImpl.cpp, function initialize(), line 382)
(Argus) Error BadParameter:  (propagating from src/eglstream/ImageImpl.cpp, function copyToNvBuffer(), line 440)
Error generated. main.cpp, threadExecute:152 Failed to copy frame to NvBuffer.
Error generated. /home/caper/users/york/jetson_multimedia_api-leopard/argus/samples/utils/Thread.cpp, threadFunction:132 (propagating)
Error generated. main.cpp, threadExecute:152 Failed to copy frame to NvBuffer.
Error generated. /home/caper/users/york/jetson_multimedia_api-leopard/argus/samples/utils/Thread.cpp, threadFunction:132 (propagating)
PRODUCER: Done -- exiting.

As I noticed, the error was thrown always at some fixed frame. For example, in my case, it’s thrown always around frame 770 as I printed the frameNumber in the console. This print line is the only line I added. It’s added like below and I don’t think this is the cause cus no matter if I add this line or not, it’s raising issue.

bool CaptureConsumerThread::processV4L2Fd(int32_t fd, uint64_t frameNumber)
{
    std::cout << "Save frame id " << frameNumber << std::endl;
    char filename[FILENAME_MAX];
    sprintf(filename, "output%03u.jpg", (unsigned) frameNumber);

    std::ofstream *outputFile = new std::ofstream(filename);
    if (outputFile)
    {
        unsigned long size = JPEG_BUFFER_SIZE;
        unsigned char *buffer = m_OutputBuffer;
        m_JpegEncoder->encodeFromFd(fd, JCS_YCbCr, &buffer, size);
        outputFile->write((char *)buffer, size);
        delete outputFile;
    }

    return true;
}

Although it was thrown from a line saying copying buffer, I noticed it’s actually related to the NvJPEGEncoder.

m_JpegEncoder->encodeFromFd(fd, JCS_YCbCr, &buffer, size); // line 297

If I comment this line out and just get the program to save empty buffers instead of the ones containing encoded bytes, it can execute correctly no matter how long I set the timeout. This is a really weird issue.

I’m testing on an AGX with Jetpack 4.3.

I hope someone can help on this. this is definitely some bug and we want to leverage this code to write some applications. Thanks

Hi,

You posted in the Jetson projects category, I am going to move this to the Jetson AGX Xavier forum so the support team will have visibility.

Tom K

ok sure

Hi,
Could you upgrade to latest Jetpack 4.6.1 and give it a try?

I can’t because currently the camera vendor’s ISP only supports jp4.3 L4T 32.3.1. If we upgrade then we can’t connect to the cameras

Hi,
There is a known issue and please try this prebuilt lib:
Jetson/L4T/r32.3.x patches - eLinux.org
[GSTREAMER]streaming using jpegenc halts after a short delay

Thanks. I’ll test it out and let you know how it goes

Tested, this works! Thanks very much!

Sorry, one more question, is this change included in newer jetpack versions?

Hi,

It is fixed in next Jetpack 4.4. If you can upgrade, we suggest upgrade to latest 4.6.1.

ok sounds good

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.