Ask Your Question

Revision history [back]

Just in case you want to try a different option to see if it helps, you can try using CamCap: https://www.ccoderun.ca/programming/doxygen/camcap/

I'm using it to capture to jpeg before processing with OpenCV. But you can also get the raw pixels so you're not having to deal with jpeg artifacts. Sample code:

#include <CamCap.hpp>

int main()
{
    CC::Device camera_device;
    camera_device.initialize(false);
    camera_device.set_all_controls_to_defaults();
    camera_device.set_format(800, 600);
    camera_device.retry_incomplete_captures(5);
    const std::string filename = "test.jpg";

    while (true)
    {
        const v4l2_buffer buffer = camera_device.capture_to_jpeg(filename);
        process(buffer, filename);
    }

    return 0;
}

(Disclaimer: I'm the author of CamCap.)