<commit_before># Vcap

## Introduction

Vcap aims to provide a concise API for working with cameras and other video capture devices that have drivers implementing the V4L2 spec. It is built on top of the libv4l userspace library (the only required dependency) which provides seamless decoding for a variety of formats.

Vcap is built with performance in mind and thus eliminates the use of dynamic memory allocation during frame grabbing. Vcap provides simple, low-level access to device controls, enabling applications to make use of the full range of functionality provided by V4L2.

This is the second iteration of Vcap, the previous version was written in 2015 when I was still a fledgling C/C++ developer. This version contains many improvements including of how formats and controls are enumerated (iterators!) and how memory is managed. Enjoy!

## Building and Installation

You must have CMake and a C compiler installed.

*$ mkdir vcap-build && cd vcap-build*

*$ cmake ../vcap && make*

To install:

*$ sudo make install*

To generate documentation (if Doxygen is installed):

*$ make docs*

There are a variety of examples available. To build the "info" example use the
following *cmake* command and run *make* again:

*$ cmake ../vcap -DBUILD\_INFO\_EXAMPLE=ON*

Other examples are built similarly.

## Example

A minimal example of grabbing a raw frame and saving it to a file (without error checking):

```c
#include <vcap/vcap.h>
#include <stdio.h>

int main(int argc, char** argv) {
    vcap_device device;

    // Find first device on the bus
    vcap_enum_devices(&device, 0);

    // Open device
    vcap_fg* fg = vcap_open(&device);

    // Set format to RGB24
    vcap_size size = { 640, 480 };
    vcap_set_fmt(fg, VCAP_FMT_RGB24, size);

    // Allocate a frame
    vcap_frame* vcap_frame = vcap_alloc_frame(fg);

    // Grab a frame
    vcap_grab(fg, frame);

    // Save raw frame
    File* file = fopen("out.raw", "wb");
    fwrite(frame->data, frame->length, 1, file);
    fclose(file);

    // Free frame
    vcap_free_frame(frame);<commit_msg>README update<commit_after># Vcap

## Introduction

Vcap aims to provide a concise API for working with cameras and other video capture devices that have drivers implementing the V4L2 spec. It is built on top of the libv4l userspace library (the only required dependency) which provides seamless decoding for a variety of formats.

Vcap is built with performance in mind and thus eliminates the use of dynamic memory allocation during frame grabbing. Vcap provides simple, low-level access to device controls, enabling applications to make use of the full range of functionality provided by V4L2.

This is the second iteration of Vcap, the previous version was written in 2015 when I was still a fledgling C/C++ developer. This version contains many improvements including of how formats and controls are enumerated (iterators!) and how memory is managed. Enjoy!

## Building and Installation

You must have CMake and a C compiler installed.

*$ mkdir vcap-build && cd vcap-build*

*$ cmake ../vcap && make*

To install:

*$ sudo make install*

To generate documentation (if Doxygen is installed):

*$ make docs*

There are a variety of examples available. To build the "info" example use the
following *cmake* command and run *make* again:

*$ cmake ../vcap -DBUILD\_INFO\_EXAMPLE=ON*

Other examples are built similarly.

## Example

A minimal example of grabbing a raw frame and saving it to a file (without error checking):

```c
#include <vcap/vcap.h>
#include <stdio.h>

int main(int argc, char** argv) {
    vcap_device device;

    // Find first device on the bus
    vcap_enum_devices(&device, 0);

    // Open device
    vcap_fg* fg = vcap_open(&device);

    // Set format to RGB24
    vcap_size size = { 640, 480 };
    vcap_set_fmt(fg, VCAP_FMT_RGB24, size);

    // Allocate a frame
    vcap_frame* vcap_frame = vcap_alloc_frame(fg);

    // Grab a frame
    vcap_grab(fg, frame);

    // Save frame as PNG
    vcap_save_png(fg, "out.png");

    // Free frame
    vcap_free_frame(frame);
{'fraction_non_alphanumeric': 0.0778296096243555, 'fraction_numerical': 0.010066290203780998, 'mean_word_length': 3.7427240977881255, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6659013', 'n_tokens_mistral': 1238, 'n_tokens_neox': 1165, 'n_words': 542}