Skip to main content

real-time window capture library based on D3D11 and Windows.Graphics.Capture

Project description

zbl

PyPI version

zbl is a Rust and Python library for screen/window capturing. It provides an interface to Windows.Graphics.Capture API with a focus on simplifying integrating computer vision applications for Windows Desktop apps.

This library is in early development stage. This means that it's only verified to work for a 'happy path' scenarios - beware of bugs!

Python

Installation

pip install zbl

Alternatively, you can install suitable wheel from releases page.

Usage

from zbl import Capture

with Capture(window_name='visual studio code') as cap:
    frame = next(cap.frames())
    print(frame.shape)

The snippet above will capture a window which title contains the string visual studio code, take one frame (which is represented as a numpy array) and print its shape.

See Capture constructor for more options. It is possible to capture the entire screen using display_id argument, for example.

To run an example using OpenCV's highgui:

  1. Install opencv-python
  2. Run python -m zbl --display-id 0

Rust

See examples. Note: if you are getting OpenCV build errors when building the example, check out how to build OpenCV rust bindings.

Comparison to mss / pyautogui

Both are very slow at the time of writing. mss tops at 30-50 fps in a tight loop, pyautogui is even slower than that. zbl is able to capture an order of magnitude faster (at 500-700 fps). This allows a lot more time for the actual processing.

Plans

  • (in progress) Integration with GpuMats & full on-GPU processing

Credits

zbl is heavily inspired by screenshot-rs.

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

zbl-0.6.0-cp312-none-win_amd64.whl (180.3 kB view hashes)

Uploaded CPython 3.12 Windows x86-64

zbl-0.6.0-cp311-none-win_amd64.whl (181.3 kB view hashes)

Uploaded CPython 3.11 Windows x86-64

zbl-0.6.0-cp310-none-win_amd64.whl (182.0 kB view hashes)

Uploaded CPython 3.10 Windows x86-64

zbl-0.6.0-cp39-none-win_amd64.whl (183.0 kB view hashes)

Uploaded CPython 3.9 Windows x86-64

zbl-0.6.0-cp38-none-win_amd64.whl (182.4 kB view hashes)

Uploaded CPython 3.8 Windows x86-64

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