motmot.wxglvideo – CPU friendly display of uncompressed video using wxPython

The wxglvideo package allows rapid display of numpy arrays into wxPython OpenGL contexts. In particular, it defines a class DynamicImageCanvas, which is a subclass of wx.glcanvas.GLCanvas into which arrays are blitted. By using the pygarrayimage module, it is possible to enforce that no copy is made of the data on its way to OpenGL, ensuring minimal resource use.

See also motmot.wxvideo.wxvideo for a similar module that does not make use of OpenGL.

Screenshot of the wxglvideo_demo program, included with wxglvideo:

Screenshot of wxglvideo_demo

motmot.wxglvideo.wxglvideo

class motmot.wxglvideo.wxglvideo.DynamicImageCanvas(*args, **kw)

Bases: wx.glcanvas.GLCanvas

Display image data to OpenGL using as few resources as possible

set_flip_LR(value)

update the view transformation to include a left-right image flip for all images

Arguments val : boolean

Whether to flip the image
set_rotate_180(value)

update the view transformation to include a 180 degree rotation for all images

Arguments

val : boolean
Whether to rotate the image
update_image(image)
update the image to be displayed

motmot.wxglvideo.simple_overlay

class motmot.wxglvideo.simple_overlay.DynamicImageCanvas(*args, **kw)

Bases: wx._windows.Panel

This class mimics the behavior of motmot.wxvideo.wxvideo.DynamicImageCanvas, allowing multiple image sources and the simple overlay of points and lines.

set_flip_LR(value)

update the view transformation to include a left-right image flip for all images

Arguments val : boolean

Whether to flip the image
set_rotate_180(value)

update the view transformation to include a 180 degree rotation for all images

Arguments

val : boolean
Whether to rotate the image
update_image_and_drawings(id_val, image, format='MONO8', points=None, point_colors=None, linesegs=None, lineseg_colors=None, xoffset=0, yoffset=0, sort_add=False)

update the displayed image

Arguments

id_val : string
An identifier for the particular source being updated
image : numpy array
The image data to update

Optional keyword arguments

format : string
The image format (e.g. ‘MONO8’, ‘RGB8’, or ‘YUV422’)
points : list of points
Points to display (e.g. [(x0,y0),(x1,y1)])
linesegs : list of line segments
Line segments to display (e.g. [(x0,y0,x1,y1),(x1,y1,x2,y2)])
class motmot.wxglvideo.simple_overlay.PointDisplayCanvas(*args, **kw)

Bases: motmot.wxglvideo.wxglvideo.DynamicImageCanvas

A single image view with overlaid points and line segments

motmot.wxglvideo.simple_overlay.copy_array_including_strides(arr)
copy a numpy array, including the strides