Xavier tegra_multimedia_api opencv

hi,
I want to know how to get the image data frome tegra_multimedia_api samples ,and convert the image date to opencv Mat.

// Acquire a frame.
            UniqueObj<Frame> frame(iFrameConsumers[i]->acquireFrame());
            IFrame *iFrame = interface_cast<IFrame>(frame);
            if (!iFrame)
                break;

            // Get the IImageNativeBuffer extension interface.
            NV::IImageNativeBuffer *iNativeBuffer =
                interface_cast<NV::IImageNativeBuffer>(iFrame->getImage());
            if (!iNativeBuffer)
                ORIGINATE_ERROR("IImageNativeBuffer not supported by Image.");

thess are the code to get the image ,but how to get the format and size of the image ,then conver to opencv Mat?

Hi,
Please refer to this patch

hi,
ok, thank you !

hi,
I have patched the file 09_camera_jpeg_capture.txt,but get the error below,then I manually modify the code.

cat main.cpp.rej
--- samples/09_camera_jpeg_capture/main.cpp
+++ samples/09_camera_jpeg_capture/main.cpp
@@ -144,8 +146,8 @@ bool ConsumerThread::threadExecute()
         if (m_dmabuf == -1)
         {
             m_dmabuf = iNativeBuffer->createNvBuffer(iStream->getResolution(),
-                                                     NvBufferColorFormat_YUV420,
-                                                     NvBufferLayout_BlockLinear);
+                                                     NvBufferColorFormat_ABGR32,
+                                                     NvBufferLayout_Pitch);
             if (m_dmabuf == -1)
                 CONSUMER_PRINT("\tFailed to create NvBuffer\n");
         }
@@ -350,7 +355,6 @@ static bool execute(NvEglRenderer *renderer)
         ORIGINATE_ERROR("Failed to get IOutputStreamSettings interface");

     iStreamSettings->setPixelFormat(PIXEL_FMT_YCbCr_420_888);
-    iStreamSettings->setEGLDisplay(renderer->getEGLDisplay());
     iStreamSettings->setResolution(PREVIEW_SIZE);
     UniqueObj<OutputStream> previewStream(iCaptureSession->createOutputStream(streamSettings.get()));
     if (DO_JPEG_ENCODE) {

when I execute the program ,it will occur the error below

nvidia@nvidia-desktop:/usr/src/tegra_multimedia_api/samples/09_camera_jpeg_capture$ ./camera_jpeg_capture
nvbuf_utils: Could not get EGL display connection
PRODUCER: Creating output stream
PRODUCER: Launching consumer thread
CONSUMER: Waiting until producer is connected...
CONSUMER: Waiting until producer is connected...
PRODUCER: Available Sensor modes :
PRODUCER: [0] W=1928 H=1208
PRODUCER: Starting repeat capture requests.
CONSUMER: Producer has connected; continuing.
CONSUMER: Producer has connected; continuing.
Segmentation fault (core dumped)

Hi,
Please run with ‘–disable-jpg’.
The JPEG encoder does not expect RGBA buffers so you need to disable it.
Also please try ‘export DISPLAY=:1’ and check if you can get information via ‘xrandr’.