Hello,
I developed a C++ application based on the libargus API examples and documentation. This application basically just stream the camera feed with a preview. It works properly as I can judge, but after more than 40 minutes an error message appears 3 times and the preview freezes.
PosixMemMap:71 [12] mmap failed
PosixMemMap:71 [12] mmap failed
PosixMemMap:71 [12] mmap failed
I also uses OpenCV to convert images and to show the preview, but hard to tell the exact time when the error appears and also hard to debug. I attached the frame conversion part of my code, because I have a feeling that is the weak point>
Image* image = iFrame->getImage();
if (!image) {
std::cerr << "Failed to get image from frame" << std::endl;
return false;
}
NV::IImageNativeBuffer* iImageNativeBuffer = interface_cast<NV::IImageNativeBuffer>(image);
if (!iImageNativeBuffer) {
std::cerr << "Failed to get native image from frame" << std::endl;
return false;
}
if (g_dmabuf == -1) {
g_dmabuf = iImageNativeBuffer->createNvBuffer(iEGLStream->getResolution(), NvBufferColorFormat_ABGR32, NvBufferLayout_Pitch);
if (g_dmabuf == -1) {
std::cerr << "Failed to create NvBuffer" << std::endl;
return false;
}
}
if (iImageNativeBuffer->copyToNvBuffer(g_dmabuf) != STATUS_OK) {
std::cerr << "Failed to copy to NvBuffer" << std::endl;
return false;
}
void* pdata = nullptr;
NvBufferParams params;
NvBufferGetParams(g_dmabuf, ¶ms);
NvBufferMemMap(g_dmabuf, 0, NvBufferMem_Read, &pdata);
NvBufferMemSyncForCpu(g_dmabuf, 0, &pdata);
cv::Mat imgbuf = cv::Mat(iSensorMode->getResolution().height(), iSensorMode->getResolution().width(), CV_8UC4, pdata, params.pitch[0]);
cv::Mat bgr;
cv::cvtColor(imgbuf, bgr, cv::COLOR_RGBA2BGR);
cv::imshow("Live Camera Feed", bgr);