NvBuffer from CUeglFrame

We are trying to use EGLStream to get image from libargus on the consumer side and feed the data to jpeg encoder.

I want to use CUeglFrame and convert it to NvBuffer (or any other and without copy), so that can use encodeFromFd or encodeFromBuffer method of JPEGEncoder to encode the data.

The samples in libargus and the 05_jpeg_encode doesn’t quite guide on how to achieve this.

Please refer to this methos and give it a try:
Argus ==> CUDA ==> JPEG - #3 by DaneLLL

Hi @DaneLLL ,

The example explains converting from EGLStream::Frame to fd (& other formats). I am looking for CUeglFrame that is received on the consumer which uses cuGraphicsResources. (via cudaEglStreamConsumerConnect() & cudaEglStreamConsumerAcquireFrame())

I am little confused on this. Are EGLStream::Frame & CUeglFrame same?

There is no method to map CUeglFrame to NvBuffer. Please have the frame data in NvBuffer and call the functions to map NvBuffer to CUeglFrame.

This is the code I am using. How do I have the frame data in NvBuffer here? If there anything needs to be on the producer (argus when creating the stream) side for this?

   // Acquire the new Bayer frame from the Argus EGLStream and get the CUDA resource.
    CUgraphicsResource bayerResource = 0;
    CUresult cuResult = cuEGLStreamConsumerAcquireFrame(
            &inputStreamConnection, &bayerResource, NULL, -1);
    if (cuResult != CUDA_SUCCESS)
        std::cout << "frame acquisition error" << std::endl;
    // Get the Bayer EGL frame information from the CUDA resource.
    CUeglFrame bayerEglFrame;
    memset(&bayerEglFrame, 0, sizeof(bayerEglFrame));
    void *dptr = NULL;
    size_t imgSize;
    cuResult = cuGraphicsResourceGetMappedEglFrame(&bayerEglFrame, bayerResource, 0, 0);
    if (cuResult != CUDA_SUCCESS)
        std::cout << "frame acquisition error: " << imgSize << std::endl;
    std::cout << "Frame acquired: " << frameCount++ << std::endl;
    cuEGLStreamConsumerReleaseFrame(&inputStreamConnection, bayerResource, NULL);

There is no method to call cuEGLStreamConsumerAcquireFrame(), cuGraphicsResourceGetMappedEglFrame() and map the data to NvBuffer. Please refer to 09_camera_jpeg_capture to call createNvBuffer() and copyToNvBuffer().

Hi @DaneLLL ,

Okay. If I understand correctly, when we need NvBuffer, we can only use EGLStream::FrameConsumer from Argus.

And when we need raw pointer (for CUDA or CPU based processing), we can use EGLStreamKHR based consumer.

If you only have CUDA processing in your use-case, you may use EGLStreamKHR based consumer. For other use-cases such as using hardware converter, encoder, CUDA processing altogether, please use EGLStream::FrameConsumer to have more flexibility.

Hi @DaneLLL ,

Thank you for confirming.

But this limits the use cases of EGL interoperability with Argus.

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