# NvBuffer from CUeglFrame

**URL:** <https://forums.developer.nvidia.com/t/nvbuffer-from-cueglframe/235493>\
**Category:** Jetson Xavier NX\
**Tags:** opengl, cuda\
**Created:** [November 27, 2022, 11:29am UTC](https://forums.developer.nvidia.com/t/nvbuffer-from-cueglframe/235493 "2022-11-27T11:29:00Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![ts-guna](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@ts-guna](https://forums.developer.nvidia.com/u/ts-guna)\
**Post date:** [November 27, 2022, 11:29am UTC](https://forums.developer.nvidia.com/t/nvbuffer-from-cueglframe/235493/1 "2022-11-27T11:29:00Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![DaneLLL](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/danelll/32/14043_2.png) [@DaneLLL](https://forums.developer.nvidia.com/u/DaneLLL)\
**Post date:** [November 28, 2022, 2:16am UTC](https://forums.developer.nvidia.com/t/nvbuffer-from-cueglframe/235493/3 "2022-11-28T02:16:01Z")

</div>

Hi,  
Please refer to this methos and give it a try:  
[Argus ==\> CUDA ==\> JPEG - #3 by DaneLLL](https://forums.developer.nvidia.com/t/argus-cuda-jpeg/235212/3)

---

<div class="post-metadata">

**Author:** ![ts-guna](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@ts-guna](https://forums.developer.nvidia.com/u/ts-guna)\
**Post date:** [November 28, 2022, 3:16am UTC](https://forums.developer.nvidia.com/t/nvbuffer-from-cueglframe/235493/4 "2022-11-28T03:16:15Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![DaneLLL](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/danelll/32/14043_2.png) [@DaneLLL](https://forums.developer.nvidia.com/u/DaneLLL)\
**Post date:** [November 28, 2022, 7:15am UTC](https://forums.developer.nvidia.com/t/nvbuffer-from-cueglframe/235493/5 "2022-11-28T07:15:08Z")

</div>

Hi,  
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.

---

<div class="post-metadata">

**Author:** ![ts-guna](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@ts-guna](https://forums.developer.nvidia.com/u/ts-guna)\
**Post date:** [November 28, 2022, 7:26am UTC](https://forums.developer.nvidia.com/t/nvbuffer-from-cueglframe/235493/6 "2022-11-28T07:26:51Z")

</div>

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);

```

---

<div class="post-metadata">

**Author:** ![DaneLLL](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/danelll/32/14043_2.png) [@DaneLLL](https://forums.developer.nvidia.com/u/DaneLLL)\
**Post date:** [November 28, 2022, 8:46am UTC](https://forums.developer.nvidia.com/t/nvbuffer-from-cueglframe/235493/7 "2022-11-28T08:46:53Z")

</div>

Hi,  
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()_.

---

<div class="post-metadata">

**Author:** ![ts-guna](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@ts-guna](https://forums.developer.nvidia.com/u/ts-guna)\
**Post date:** [November 28, 2022, 9:15am UTC](https://forums.developer.nvidia.com/t/nvbuffer-from-cueglframe/235493/8 "2022-11-28T09:15:36Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![DaneLLL](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/danelll/32/14043_2.png) [@DaneLLL](https://forums.developer.nvidia.com/u/DaneLLL)\
**Post date:** [November 28, 2022, 12:47pm UTC](https://forums.developer.nvidia.com/t/nvbuffer-from-cueglframe/235493/9 "2022-11-28T12:47:44Z")

</div>

Hi,  
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.

---

<div class="post-metadata">

**Author:** ![ts-guna](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@ts-guna](https://forums.developer.nvidia.com/u/ts-guna)\
**Post date:** [November 28, 2022, 12:55pm UTC](https://forums.developer.nvidia.com/t/nvbuffer-from-cueglframe/235493/10 "2022-11-28T12:55:04Z")

</div>

Hi @DaneLLL ,

Thank you for confirming.

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

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/system/32/68080_2.png) [@system](https://forums.developer.nvidia.com/u/system)\
**Post date:** [December 21, 2022, 1:05am UTC](https://forums.developer.nvidia.com/t/nvbuffer-from-cueglframe/235493/12 "2022-12-21T01:05:48Z")

</div>

Closed on December 21, 2022, 1:05am UTC

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