Skip to main content

OpenCV Playground

The OpenCV Playground is a Qt6 application that brings together improved documentation alongside OpenCV functions with the ability to explore the effects of function parameters on an image in real time.

It also comes with a custom Pipeline Launcher that allows you to build and interact with your own sequence of image transformations along with custom build functions.

Full documentation can be found on Read the Docs.

Demo

Installation

Currently tested with python 3.8.10/3.10.0 and opencv-contrib-python-headless 4.8.0.76 on an M1 Mac.

From PyPi:

pip install opencv-pg

From Github Repo:

pip install git+https://github.com/opencv-pg/opencv-pg

Note for Linux Users

NOTE: I no longer have access to anything but a Mac (as of 1.0.2), so I can't confirm if the below still stands. It did in 1.0.1.

On Ubuntu 16.04 (others currently untested), there may be missing links to xcb related shared objects.

tldr;

sudo apt-get install --reinstall libxcb-xinerama0

Digging Deeper

If you see errors about xcb, you can perform the following to help troubleshoot. In your terminal, make the following export:

export QT_DEBUG_PLUGINS=1

Run opencvpg again and validate the output. The final lines will likely mention details about files not found. Likely libxcb-xinerama.so.0.

Run the following:

cd your_venv/lib/pythonX.X/site-packages/PySide2/Qt/plugins/platforms/
ldd libqxcb.so | grep "not found"

This will print any missing links. In our case, libxcb-xinerama.so.0 showed up a couple times. Reinstalling the package as follows resolved the issue:

sudo apt-get install --reinstall libxcb-xinerama0

Once it’s working, you may want to disable that QT_DEBUG_PLUGINS env variable so it doesn’t throw extra garbage in your output.

Usage

Playground

To launch the OpenCV Playground with:

  • The built-in image:
opencvpg
  • An image of your choice:
opencvpg --image <path-to-image.png>
  • Without the documentation window:
opencvpg --no-docs

Custom Pipeline

The following is an example of building a custom Pipeline.

from opencv_pg import Pipeline, Window, launch_pipeline
from opencv_pg import support_transforms as supt
from opencv_pg import transforms as tf

if __name__ == '__main__':
    my_image = '/path/to/image.png'

    # Creates two windows
    pipeline = Pipeline([
        Window([
            supt.LoadImage(my_image),
            supt.CvtColor(),
            tf.InRange(),
            supt.BitwiseAnd(),
        ]),
        Window([
            tf.Canny(),
        ]),
    ])

    launch_pipeline(pipeline)

Then run the file.

Development

Installation

To install in development mode:

git clone https://github.com/opencv-pg/opencv-pg
pip install -e opencv-pg/[dev]

Running Tests

cd tests
pytest

Generating Docs

  • Go into the top level docs directory
  • run sphinx-apidoc -f -o source/ ../src/opencv_pg
  • run make html

Output will be in the docs/build/html/ directory.

Metadata

Release files for opencv-pg 1.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for opencv-pg 1.0.2
File Size Uploaded
opencv_pg-1.0.2.tar.gz 6.3 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for opencv-pg 1.0.2
File Interpreter ABI Platform
opencv_pg-1.0.2-py3-none-any.whl Python 3 none any Details

Total release size: 12.7 MB

Release files / opencv_pg-1.0.2.tar.gz

Download URL opencv_pg-1.0.2.tar.gz
Size 6.3 MB
Tags Source
SHA-256 checksum
How to use checksums
f09919d92dc775d0f3e5b1b024a64edefd8b5dd301c588a88d424b088ba79805
BLAKE2b-256 checksum
How to use checksums
c75b27bc2c98ff80daf6e8ccf24aeab683d7bccb3755e4522c5ebaf676f630ce
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.0

Release files / opencv_pg-1.0.2-py3-none-any.whl

Download URL opencv_pg-1.0.2-py3-none-any.whl
Size 6.4 MB
Tags Python 3
SHA-256 checksum
How to use checksums
4f966a8abfa8acceb871e3eb4b07d94b53b9a59eb4f09d74fe8333bd9c1f8849
BLAKE2b-256 checksum
How to use checksums
c83c26b5cb889d721b510495dbe302009bae7981db77aa45ab387f6ce0dbaa80
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.0

Release history Release notifications | RSS feed

This release

1.0.2 This release

2 release files

1.0.1

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page