Skip to main content

Python interface for Magewell ProCapture SDK

Project description

pymagewell

pymagewell is a Python library for interfacing with Magewell ProCapture frame grabbers.

It is based on (and includes) Magewell's Windows SDK and is therefore Windows only. However, it provides a mock class that for testing and development that does not depend on the SDK's Windows .dll files, so pymagwell can also be installed on macOS and Linux.

Installation

From PyPI:

pip install pymagewell

From conda-forge (Windows and macOS only):

conda install -c conda-forge pymagewell

Example of use

A full working example is provided in example_script.py.

First, create a ProCaptureSettings dataclass:

from pymagewell import (
    ProCaptureSettings, ImageSizeInPixels, TransferMode, ColourFormat
)

device_settings = ProCaptureSettings(
    dimensions=ImageSizeInPixels(1920, 1080),
    color_format=ColourFormat.BGR24,  # Color format of captured video frames
    transfer_mode=TransferMode.LOW_LATENCY,
    num_lines_per_chunk=64  # has effect only in low latency mode
)

Then create a ProCaptureDevice (or MockProCaptureDevice for testing on a system without a grabber) configured with your chosen settings:

from pymagewell import ProCaptureDevice

device = ProCaptureDevice(settings=device_settings)

Then create a ProCaptureDeviceController to transfer frames from the device to your PC:

from pymagewell import ProCaptureController

controller = ProCaptureController(device)

Then you can grab frames in a loop using the transfer_when_ready() method, which will wait until a frame has been acquired by the device, transfer it from the device to the PC, and return it as a VideoFrame object. This is a blocking call.

while True:
    frame = controller.transfer_when_ready()

VideoFrame provides access to the pixels as a Numpy array with its as_array method. It also provides access to timestamps (datetime.datetime) describing the frame acquisition process:

t1 = frame.timestamps.buffering_started  # time at which frame started being written to the hardware buffer
buffer
t2 = frame.timestamps.buffering_complete  # time at which frame was completely written to the hardware buffer
t3 = frame.timestamps.transfer_started  # time at which the software started transferring the frame to PC memory
t4 = frame.timestamps.transfer_complete  # time by which the whole frame had arrived in PC memory

In TIMER and NORMAL transfer modes, transfer starts after the full frame has been written to hardware buffer. In LOW_LATENCY transfer mode, transfer starts while the frame is still being written to hardware memory. This will be reflected in the timestamps.

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

pymagewell-0.2.1.tar.gz (28.0 MB view details)

Uploaded Source

Built Distribution

pymagewell-0.2.1-py3-none-any.whl (28.1 MB view details)

Uploaded Python 3

File details

Details for the file pymagewell-0.2.1.tar.gz.

File metadata

  • Download URL: pymagewell-0.2.1.tar.gz
  • Upload date:
  • Size: 28.0 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.6

File hashes

Hashes for pymagewell-0.2.1.tar.gz
Algorithm Hash digest
SHA256 70cdf755fe6001a871a97b987f1e9b3d67ba97f5f2a23675f6e0fa717a457a37
MD5 43e18b527279201671b783a02efc191f
BLAKE2b-256 fadda858e6cdca2662144d57ef76817345ecd8ef769d9b056b6721bb64150f29

See more details on using hashes here.

File details

Details for the file pymagewell-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: pymagewell-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 28.1 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.6

File hashes

Hashes for pymagewell-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 c160040f44318252aa7385253284c0152326e17b0d56471a5c6825b91b1a4bb5
MD5 6f926810c42780c214c491349802fd14
BLAKE2b-256 6fe95a9ec09aadf17417fdfd2b864e174ebd9b853f4caa33edd3e65af0d1ffcb

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