I’m using
tx1 with four csi camera.
4 camera to dump yuv to ssd.
I try to use four thread to do the following job
but after about 10min. one of my camera can never acquireFrame.
IFrameConsumer *iFrameConsumer = interface_cast(m_consumer[devIndex]);
auto pframe = iFrameConsumer->acquireFrame();
IFrame *iFrame = interface_cast
NV::IImageNativeBuffer *iNativeBuffer = interface_castNV::IImageNativeBuffer(iFrame->getImage());
if (m_dmabuff[devIndex] == -1) {
m_dmabuff[devIndex] =
iNativeBuffer->createNvBuffer(Size(1280, 720), NvBufferColorFormat_YUV420, NvBufferLayout_Pitch);
} else {
iNativeBuffer->copyToNvBuffer(m_dmabuff[devIndex]);
}
NvBufferParams params;
NvBufferGetParams(m_dmabuff[devIndex], ¶ms);
char path[256];
snprintf(path, sizeof(path), “%s%d_%llu.yuv”, dir_name, devIndex, static_cast(iFrame->getTime()));
FILE *fp = fopen(path, “wb”);
for (unsigned i = 0; i < params.num_planes; i++) {
size_t size = params.height[i] * params.pitch[i];
// size_t size = params.psize[i];
char *vptr = (char *)mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, m_dmabuff[devIndex], params.offset[i]);
for (unsigned j = 0; j < params.height[i]; j++) {
fwrite(vptr + params.pitch[i] * j, params.width[i], 1, fp);
}
if (munmap(vptr, size)) {
LOG(ERROR) << "unable to unmap " << devIndex;
}
}
fclose(fp);
pframe->destroy();
return 0;