The image saved from the data retrieved from the V4L2 queue is incomplete. The capture process also involved a select
call to wait for a complete frame. Could there be an issue with the VI (Video Input) part?
while (m_IsStreamRunning)
{
fd_set fds;
struct timeval tv;
int result = -1;
FD_ZERO(&fds);
FD_SET(m_nFileDescriptor, &fds);
if (m_BlockingMode)
{
/* Timeout. */
tv.tv_sec = 1;
tv.tv_usec = 0;
result = select(m_nFileDescriptor + 1, &fds, NULL, NULL, &tv);
if (result == -1)
{
// Error
continue;
}
else if (result == 0)
{
// Timeout
usleep(2*1000);
continue;
}
else
{
DequeueAndProcessFrame();
}
}
// non-blocking mode
else
{
DequeueAndProcessFrame();
}
}
buffer queue:
uint8_t *rawBuffer = new uint8_t[buf.payloadSize];
memcpy(rawBuffer, buf.data, buf.payloadSize);
BufferWrapper frameBuffer = {buf.buffer, rawBuffer, buf.length, buf.width, buf.height, buf.pixelFormat, buf.payloadSize, buf.bytesPerLine, buf.frameID};
frameQueue.push(frameBuffer);
if(lastDoneCallback) {
lastDoneCallback();
}
lastDoneCallback = doneCallback;
Gets data from the queue to save: