I’m still very confused.
In the 09_camera_jepg_capture program, I know that bool ConsumerThread::threadExecute() captures the incoming video frames and I was under the impression that I could just use/copy m_dmabuf instead of creating another buffer.
Am I correct with that assumption or no?
My second question is that once either the m_dmabuf is either copied again or a second buffer is created what’s the best way to get the height/width of the image that’s saved in the mentioned buffer(s)?
For what it’s worth, here’s where I currently stand with the 09_camera_jpeg_capture example with the bool ConsumerThread::threadExecute() function
bool ConsumerThread::threadExecute()
{
IEGLOutputStream *iEglOutputStream = interface_cast<IEGLOutputStream>(m_stream);
IFrameConsumer *iFrameConsumer = interface_cast<IFrameConsumer>(m_consumer);
/* Wait until the producer has connected to the stream. */
CONSUMER_PRINT("Waiting until producer is connected...\n");
if (iEglOutputStream->waitUntilConnected() != STATUS_OK)
ORIGINATE_ERROR("Stream failed to connect.");
CONSUMER_PRINT("Producer has connected; continuing.\n");
int second_dmabuf = -1;
while (true)
{
/* Acquire a frame. */
UniqueObj<Frame> frame(iFrameConsumer->acquireFrame());
IFrame *iFrame = interface_cast<IFrame>(frame);
if (!iFrame)
break;
/* Get the IImageNativeBuffer extension interface. */
// Get access to image data through iFrame->getImage();
// Image data can be retrieved and processed through ' IImageNativeBuffer interface.
NV::IImageNativeBuffer *iNativeBuffer = interface_cast<NV::IImageNativeBuffer>(iFrame->getImage());
if (!iNativeBuffer)
ORIGINATE_ERROR("IImageNativeBuffer not supported by Image.");
/* If we don't already have a buffer, create one from this image.
Otherwise, just blit to our buffer. */
if (m_dmabuf == -1)
{
/*
virtual int EGLStream::NV::IImageNativeBuffer::createNvBuffer(Argus::Size2D<...> size, NvBufferColorFormat format, NvBufferLayout layout, EGLStream::NV::Rotation rotation = EGLStream::NV::ROTATION_0, Argus::Status *status = (Argus::Status *)__null) const
Returns -1 on failure
Returns valid dmabuf-fd on success
*/
m_dmabuf = iNativeBuffer->createNvBuffer(iEglOutputStream->getResolution(),
NvBufferColorFormat_YUV420,
NvBufferLayout_BlockLinear);
second_dmabuf = iNativeBuffer->createNvBuffer(iEglOutputStream->getResolution(),
NvBufferColorFormat_YUV420,
NvBufferLayout_BlockLinear);
if (m_dmabuf == -1 || second_dmabuf == -1)
CONSUMER_PRINT("\tFailed to create NvBuffer\n");
else
CONSUMER_PRINT("\nBUFFER CREATED\n");
}
else if (iNativeBuffer->copyToNvBuffer(m_dmabuf) != STATUS_OK || iNativeBuffer->copyToNvBuffer(second_dmabuf) != STATUS_OK)
{
ORIGINATE_ERROR("Failed to copy frame to NvBuffer.");
}
/* Process frame to be written. */
// bool CaptureConsumerThread::processV4L2Fd(int32_t fd, uint64_t frameNumber)
processV4L2Fd(m_dmabuf, iFrame->getNumber());
}
CONSUMER_PRINT("Done.\n");
requestShutdown();
return true;
}