Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Python bindings

The viva-genicam Python package wraps the Rust workspace behind a NumPy-friendly API. It ships as a pre-built wheel on PyPI — no C toolchain, no aravis, no system USB library.

pip install viva-genicam

The install also provides the viva-camctl CLI — see Install & hello-camera.

import viva_genicam as vg

cams = vg.discover(timeout_ms=500)
with vg.connect_gige(cams[0]) as cam:    # control is given back at the end
    print(cam.get("DeviceModelName"))

    with cam.stream() as frames:
        for frame in frames:
            arr = frame.to_numpy()       # shape and dtype follow the pixel format
            break

to_numpy() returns the camera’s values: (H, W) uint8 for 8-bit monochrome, (H, W) uint16 for 10- to 16-bit monochrome, packed or not, a Bayer mosaic as sent unless asked to demosaic it, and (H, W, 3) uint8 for RGB and BGR — see Streaming → to_numpy().

A camera, a frame and a stream may be used from any thread, and every call that waits on the camera lets other Python threads run.

Tutorials

  1. Install & hello-camera — install the wheel, run the self-contained fake-camera demo.
  2. Discovery — enumerate GigE and U3V cameras, restrict to one NIC.
  3. Control & introspection — read and write features, walk the NodeMap, discover which features apply.
  4. Streaming — context-manager streams, NumPy frames, pixel formats, timestamps.

Reference

  • API reference — every public class, function, and exception in one place.
  • Example scripts — runnable Python files mirroring the most common Rust examples.

Supported

GigE Vision and USB3 Vision discovery, control and streaming. Supported Python versions and the platforms with pre-built wheels are listed in Install & hello-camera.

Not exposed to Python yet

The Rust API is wider than the bindings. These exist in viva-genicam and have no Python equivalent today:

  • Chunk data. frame.chunks is not surfaced; ChunkConfig, configure_chunks and the chunk features (Camera::chunk_features) are Rust-only.
  • Events. There is no binding for the message channel or EventStream.
  • Action commands and FORCEIP / persistent IP configuration. (GenApi <Command> features — UserSetLoad, TriggerSoftware — are a different thing and are exposed, via cam.execute(name); see Control.)

If you need one of these, viva-camctl covers most of them from the command line, and the Rust crates cover all of them.