The image saved from the data retrieved from the V4L2 queue is incomplete

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:



Hello @shenchengzha,

That un our experience might be a timmimg issue.

You could check your timming configuration on your board and the register tables used on the camera.

Just a couple of questions.

  1. What camera are you using ?
  2. Did you developed the camera driver ?
  3. Do you have access to the driver source code ?

Pleae let us kow if you require further assistance, we are happy to help.

Regards,
Andrew

1 Like

Hello, thanks for your support. The driver is our own development, is to access the driver source code, how to troubleshoot this problem?

Do you confirm by v4l2-ctl?

Hello @shenchengzha,

@ShaneCCC is right, you could try capturing with v4l2-ctl just to see if it bahces the same.

Given that you are writing the driver yourlseves, you could try playing with the sensor timming configurations.

Also, make sure your DTB module is configured propperly.

Regards,
Andrew

Yes, I collected it using the v4l2-ctl command.

@shenchengzha,

Thanks for getting back.

If you captured those images with v4l2-ctl, then it rules out GStreamer and nvarguscam.
It sounds like sensor configuration.

Do you have access to the sensor datasheet ?

regards,
Andrew

Please check the trace log to get more information.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.