Skip to content

Video4Linux

DmtKats edited this page Nov 29, 2016 · 12 revisions

Introduction

Video4Linux, or for sorter v4l, is an API and a set of drivers implementing it, for real time capture of video in Linux. There are multiple multiple usb, webcam and TV tuners supporting this API, thus making it easier for software developers to add video support to their applications. Currently, the supported version of v4l is version 2, or v4l2. For additional information you can check the official site as well as the Linux Media Subsystem Documentation

Overview of chapter

For the QTec cameras, we support the v4l2 API. Thus, the features of the camera can be controlled via your applications. Not only do we support the c API, but we also provide a Python3 binding of the API, as well as the v4l2wrapper, a library that provides a simplified interface for handling all the features of the camera. In this tutorial we will go over the following:

  • [Installation] (#installation)
  • [Adding the wrapper to a Python3 script] (#addingchap)
  • [Capture an image] (#capture)
  • [Get and set controls] (#getsetctrl)
  • [Streaming video] (#streaming)

For now we will only talk about using v4l2 in Python. If you wish to see how to add v4l2 to a C application, please check out the tutorial on GCC

Installation

On the command line run:

apt-get update
apt-get install python3-v4l2wrapper

This will install the v4l2 bindings and the v4l2 wrapper. If you just want the bindings just run

apt-get update
apt-get install python3-v4l2

Adding the bindings and wrapper to a Python3 script

Adding the bindings and wrapper is as simple as:

import v4l2
from v4l2wrapper import create_device_wrapper

create_device_wrapper is the function that will generate the wrapper for us. All we have to do is:

wrapper = create_device_wrapper()

Getting an image

setting control properties

streaming video