Skip to main content

Simple Python native access library for Video4Linux camera devices

Project description

Simple Python native access library for Video4Linux camera devices

Warning: Work (slowly) in progress. Currently hardwired to YUV format. This will be fixed soon

This is a simple library that allows one to access camera devices accessible via Video4Linux from Python without using libraries with huge dependency chains that allows easy and fast testing of ideas and algorithms for image processing before implementing them in a proper way in some programming language such as C. It’s built in the most simple way on purpose.

Tested on:

  • Python 3.8:

    • FreeBSD 12 (amd64, aarch64)

    • FreeBSD 13 (amd64, aarch64)

Currently not implemented / not optimal

  • Currently the library does not support anything else than YUV422 captures from the cameras and only outputs RGB888 images as nested Python lists. This will be fixed as soon as possible but will introduce a breaking change.

Installing via PyPi

The package is available as a source distribution via PyPi:

pip install simplepycam-tspspi

Building

Use setup.py in cext:

$ python setup.py build

Example usage

More sophisticated examples can be found in the samples directory.

Using the stream callback interface, the default format and with

import simplepycam

def processFrame(camera, frame):
    if shouldStopProcessing:
        return False
    else:
        return True

with simplepycam.Camera("/dev/video0") as cam:
    cam.frameCallback = [ processFrame ]
    cam.stream()

Using the stream callback interface, the default format and open/close

import simplepycam

def processFrame(camera, frame):
    if shouldStopProcessing:
        return False
    else:
        return True

cam = simplepycam.Camera("/dev/video0")
cam.open()
cam.frameCallback = [ processFrame ]
cam.stream()
cam.close()

Using the polling API, the default format and with

import simplepycam

with simplepycam.Camera("/dev/video0") as cam:
    cam.streamOn()
    for i in range(100):
        frame = cam.nextFrame()
    cam.streamOff()

Using the polling API, the default format and open/close

import simplepycam

cam = simplepycam.Camera("/dev/video0")
cam.open()
cam.streamOn()
for i in range(100):
    frame = cam.nextFrame()
cam.streamOff()
cam.close()

API documentation

UML diagram of Python side

UML diagram of Python side

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

simplepycam-tspspi-0.1.3.tar.gz (11.1 kB view details)

Uploaded Source

File details

Details for the file simplepycam-tspspi-0.1.3.tar.gz.

File metadata

  • Download URL: simplepycam-tspspi-0.1.3.tar.gz
  • Upload date:
  • Size: 11.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.8.13

File hashes

Hashes for simplepycam-tspspi-0.1.3.tar.gz
Algorithm Hash digest
SHA256 3fae90133af258449d99d9695cac47c1e60e216ec06f9bcc9eadf2a3ff6a2e6a
MD5 2f4241d035902a355d956741156a9c1c
BLAKE2b-256 5d43dbff1c4dda9ae6e95e388565b321a87bca148dff17927a42dd1cbdc12d03

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page