Basically, I’m looking for JP5.1 version of this snippet
// Copy the image into an OpenCV Mat object. Note that OpenCV Matrix objects store the color
// channels in the order of blue, green, and red (hence the "bgr" naming convention).
auto *iNativeBuffer = Argus::interface_cast<EGLStream::NV::IImageNativeBuffer>(iFrame->getImage());
if (!iNativeBuffer) {
ORIGINATE_ERROR("IImageNativeBuffer not supported by Image.");
}
if (m_dmabuf == -1) {
m_dmabuf = iNativeBuffer->createNvBuffer(
streamResolution,
NvBufferColorFormat_ABGR32,
NvBufferLayout_Pitch);
if (m_dmabuf == -1) {
ORIGINATE_ERROR("\tFailed to create NvBuffer\n");
}
}
if (iNativeBuffer->copyToNvBuffer(m_dmabuf) != Argus::STATUS_OK) {
ORIGINATE_ERROR("Failed to copy frame to NvBuffer.");
}
void *pdata = nullptr;
NvBufferParams params;
NvBufferGetParams(m_dmabuf, ¶ms);
NvBufferMemMap(m_dmabuf, plane, NvBufferMem_Read, &pdata);
NvBufferMemSyncForCpu(m_dmabuf, plane, &pdata);
cv::Mat imgbuf = cv::Mat(streamResolution.height(), streamResolution.width(), CV_8UC4, pdata, params.pitch[0]);
cv::cvtColor(imgbuf, bgr, cv::COLOR_RGBA2BGR);
Can you please provide an example that would work with the 09_argus_camera_jpeg sample application? Thank you.
Hi @DaneLLL , I have and that is not the problem I’m currently facing. The issue is that the cv::Mat generated looks to have the wrong color channels. Could you please tell me what to replace the NvBufferColorFormat_ABGR32 and the color conversion cv::COLOR_RGBA2BGR` flags with?
I have tried a number of combinations of the following flags, and none of them seem to work. Seems like the order of the channels is no longer consistent.
NvBuffer flags tried
NVBUF_COLOR_FORMAT_RGBA
NVBUF_COLOR_FORMAT_BGRA
NVBUF_COLOR_FORMAT_ARGB
NVBUF_COLOR_FORMAT_ABGR
OpenCV color conversions tried
COLOR_RGBA2BGR
COLOR_BGRA2BGR
Which combinations of these would yield the same results as in the snippet in question? Thanks.