Skip to main content

https://github.com/aieater/python_glview

pyglview (Python OpenGL viewer library)

Description

OpenCV3 renderer is too slow due to cv2.waitKey(1). If you want to more performance, you should use OpenCV4+ or 'pyglview' package.

This package is supported fastest OpenGL direct viewer and OpenCV renderer both. If your environment was not supported OpenGL, it will be switched to CPU renderer(OpenCV) automatically and also available remote desktop(Xserver) like VNC.

pyglview is useful library instead of OpenCV imshow/waitKey API.

Getting Started

AMD Radeon GPU driver on Ubuntu
curl -sL http://install.aieater.com/setup_rocm | bash -
NVIDIA GPU driver on Ubuntu
curl -sL http://install.aieater.com/setup_nvidia_with_cuda10 | sudo bash -
Desktop package (optional)

Ubuntu16

sudo apt update
sudo apt install -y ubuntu-desktop

For remote desktop.

sudo apt install -y gnome-panel gnome-settings-daemon metacity nautilus gnome-terminal vnc4server

Also see xstartup template script => http://install.aieater.com/xstartup

Install OpenGL packages

Install OpenGL native packages, (Ubuntu16/18)

# Full OpenGL packages.
sudo apt install -y build-essential
sudo apt install -y libgtkglext1 libgtkglext1-dev
sudo apt install -y libgl1-mesa-dev libglu1-mesa-dev mesa-utils
sudo apt install -y freeglut3-dev libglew1.10 libglew-dev libgl1-mesa-glx libxmu-dev
sudo apt install -y libglew-dev libsdl2-dev libsdl2-image-dev libglm-dev libfreetype6-dev

Install python packages (Linux/MacOSX/Windows)

pip3 install PyOpenGL PyOpenGL_accelerate
Python package dependencies
Version Library installation
v3.x/v4.x OpenCV pip3 install opencv-python
v1.1x.x numpy pip3 install numpy
v3.1.x PyOpenGL pip3 install PyOpenGL
v3.7.x configparser pip3 install configparser

Finally, install pyglview.

pip3 install pyglview

Examples

import cv2
import pyglview
viewer = pyglview.Viewer()
cap = cv2.VideoCapture(os.path.join(os.path.expanduser('~'),"test.mp4"))
def loop():
    check,frame = cap.read()
    frame = cv2.cvtColor(frame,cv2.COLOR_BGR2RGB)
    if check:
        viewer.set_image(frame)
viewer.set_loop(loop)
viewer.start()

If you got something warning message, it is not using GPU.

Message type

Use GPU directly

This message is successful to use GPU.

@WARNING: No display.

No display message meaning is there is no available display. This message will be appeared, when you have executed program in ssh console.

@WARNING: GPU or physical display is not available. Use CPU renderer.

This message will be appeared, when there was no GPU or GPU driver, or remote logged in like VNC. You have to make sure GPU driver and PyOpenGL packages and use physical display.

Also see 'acapture' package

If you want to more performance and non-blocking API for camera and video, acapture package is very useful.

acapture + pyglview + webcamera example.

import cv2
import acapture
import pyglview
viewer = pyglview.Viewer()
cap = acapture.open(0) # Camera 0,  /dev/video0
def loop():
    check,frame = cap.read() # non-blocking
    frame = cv2.cvtColor(frame,cv2.COLOR_BGR2RGB)
    if check:
        viewer.set_image(frame)
viewer.set_loop(loop)
viewer.start()

Logicool C922 1280x720(HD) is supported 60FPS. This camera device and OpenGL direct renderer is best practice. Logicool BRIO 90FPS camera is also good!, but little bit expensive.

License

This project is licensed under the MIT License - see the LICENSE file for details

Metadata

Release files for pyglview 1.3.4

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

Source distribution (sdist)

Source distribution for pyglview 1.3.4
File Size Uploaded
pyglview-1.3.4.tar.gz 8.0 kB Details

Release files / pyglview-1.3.4.tar.gz

Download URL pyglview-1.3.4.tar.gz
Size 8.0 kB
Tags Source
SHA-256 checksum
How to use checksums
bcfa20c0a9b05c68afd3f9b5b07651f76d6600b986ef25f335f1a98f277c143b
BLAKE2b-256 checksum
How to use checksums
8894f8cb9ad6e81cf174cb58fc52d64f1f710717ade725cad34b3edc1777cc74
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.2.0 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.8.5

Release history Release notifications | RSS feed

This release

1.3.4 This release

1 release file

1.3.3

1 release file

1.3.2

1 release file

1.3.0

1 release file

1.2.0

1 release file

1.1.10

1 release file

1.1.9

1 release file

1.1.8

1 release file

1.1.7

1 release file

1.1.6

1 release file

1.1.5

1 release file

1.1.4

1 release file

1.1.3

1 release file

1.1.2

1 release file

1.1.1

1 release file

1.1

1 release file

1.0

1 release file

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