jvconnected.devicepreview

class jvconnected.devicepreview.JpegSource(device: jvconnected.device.Device, fps: int = 30)[source]

Bases: object

Acquire preview images sequentially from the device

This acts an Asynchronous Context Manager and an Asynchronous Iterator and should be used within an async with block. The individual image frames can then be retreived using an async for loop:

async with JpegSource(device) as src:
    async for image_bytes in src:
        process_image(image_bytes)
device: jvconnected.device.Device

The device instance

fps: int = 30

Desired frame rate in frames per second

property encodingbool [read-only]

True if the camera’s Jpeg encode function is enabled

async acquire()[source]

Acquire the context manager and tell the device to begin Jpeg encoding

async release()[source]

Stop encoding on the device and release the context manager

async wait_for_next_frame()[source]

Wait for enough time to elapse to respect the required fps

async get_single_image() → Optional[bytes][source]

Get a single frame as a bytes of Jpeg encoded data

If necessary, wait before requesting to maintain the desired fps

Note

The object must be acquired before calling this method, either by acquire() or async with