CamCap  v0.0.1-2786
C++ camera capture library and tool
CamCap Documentation

CamCap is both a C++ library and a command-line tool. It is used to access webcams via Video4Linux, also known as V4L or V4L2.

The official V4L documentation is here: https://www.linuxtv.org/docs.php

The goal of the CamCap library isn't to behave as a wrapper for V4L, but to provide an easy-to-use C++ interface specifically to access cameras such as web cams.

The functionality most likely to be used (e.g., "take a picture") should be accessible with very few API calls:

#include <CamCap.hpp>
int main()
{
// instantiate a camera device object
CC::Device camera_device;
// take a picture and store it as a jpeg file
camera_device.capture_to_jpeg( "/tmp/output.jpg" );
return 0;
}

The CC::Device class tries to choose reasonable defaults. But if needed, many settings can be specified manually. For example:

#include <CamCap.hpp>
int main()
{
// instantiate a camera device object
CC::Device camera_device;
// initialize a very specific device, not the first one found
camera_device.initialize( "/dev/video3" );
// use a specific pixel format, such as 24-bit RGB (V4L2_PIX_FMT_RGB24) or YUYV 4:2:2 (V4L2_PIX_FMT_YUYV)
camera_device.set_format( V4L2_PIX_FMT_YUYV, 1280, 960 );
// don't change the pixel format but set a specific size (camera will pick nearest usable dimensions)
camera_device.set_format( 800, 600 );
// take a picture and return the bytes; format depends on the "pixel format" set in set_format()
CC::Bytes bytes = camera_device.capture();
// ...or if you also want access to the meta data (timestamps, sequence numbers, ...)
CC::Bytes bytes;
v4l2_buffer image_info = camera_device.capture( bytes );
return 0;
}