GithubHelp home page GithubHelp logo

v4l2cxx's Introduction

Video4Linux2 C++ simple wrapper

Intro

A simple C++ header library to capture frames from a usb camera into a callback function for image processing.

How to use

Run a simple hello camera to see how easy. no more v4l2 boilrplate code.

// callback function to pipe out image to stdout 
// later pipe to ffplay to display image
void callback_stdout_pipe(uint8_t *p_data, size_t len) {
    uint8_t outBuff[921600];
    util_v4l2::raw_to_rgb(p_data, 0, outBuff, 921600, 640 * 480, 8);
    fwrite(outBuff, 640*480*3, 1, stdout);
}

int main() {
    // a capture instance 
    // device, resolution, pixel format , and callback function this should be known in advance you can use 
    // v4l2-ctl command to figure that out.
    capture cap("/dev/video0", 640,480,pixel_format ::V4L2CXX_PIX_FMT_YUYV,callback_stdout_pipe);
    // start streaming - a blocking function.
    cap.run();
}

Examples

  • TODO ; cmake; See example folder

v4l2 Extension unit

  • TODO
  • TODO example with LI-USB30-V034M

pipe to ffplay

./libv4l2cxx | ffplay -f rawvideo -i pipe:0 -video_size 640x480 -pixel_format rgb24 -framerate 60

ffmpeg commands

Play video device

ffplay -f v4l2 -i /dev/video0 -video_size 640x480 -pixel_format yuyv422 -framerate 30

ffplay -f v4l2 -i /dev/video0 -video_size 640x480 -pixel_format mjpeg

ffplay -f v4l2 -i /dev/video0 -video_size 1280x720 -pixel_format mjpeg -framerate 30

Pipe libv4l2 to ffplay, tell ffplay to use input (-i pipe:0 = stdin standrd input)

./libv4l2cxx | ffplay -f rawvideo -i pipe:0 -video_size 640x480 -pixel_format rgb24 -framerate 60

List formats for device

v4l2-ctl --list-formats

List exdtended formats including resolution info for device

v4l2-ctl --list-formats-ext

v4l2-ctl -L

List controls for device

v4l2-ctl --all

Change control option to value

v4l2-ctl -c <option>=<value>

v4l2-ctl -d /dev/video1 -c exposure_absolute=100

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.