async2v.components.pygame.display module¶
Summary¶
Classes:
AuxiliaryDisplay |
Abstract auxiliary display sub-component |
AuxiliaryDisplayConfig |
Configuration for the AuxiliaryDisplay component |
AuxiliaryDisplayConfigurator |
Configuration for the AuxiliaryDisplay component |
AuxiliaryOpenCvDisplay |
Draw OpenCV frames to the auxiliary display surface. |
Display |
Abstract pygame display |
OpenCvDebugDisplay |
Zero configuration pygame debug display |
OpenCvDisplay |
Pygame display drawing OpenCV frames |
OpenCvMultiDisplay |
Pygame display drawing OpenCV frames from multiple sources |
Reference¶
-
class
Display
¶ Bases:
async2v.components.base.SubComponent
Abstract pygame display
The pygame
MainWindow
supports multiple displays. The currently selected display is rendered on the main display area. An optionalAuxiliaryDisplay
can be rendered next to the main display area.-
draw
(surface)¶ This method needs to overridden to draw the content of the display to the given surface.
Parameters: surface ( Surface
) – Pygame surface that can be used completely to draw the content of this displayReturn type: List
[MouseRegion
]Returns: List of mouse regions relative to the given surface. For those regions, mouse events will be emitted by the containing MainWindow
. Seemouse
for details.
-
-
class
AuxiliaryDisplayConfig
(resolution)¶ Bases:
object
Configuration for the
AuxiliaryDisplay
component-
resolution
= None¶ Type: Tuple[int, int] Resolution (width, height)
-
-
class
AuxiliaryDisplayConfigurator
¶ Bases:
async2v.cli.Configurator
Configuration for the
AuxiliaryDisplay
component-
static
config_from_args
(args)¶ Get configuration from argparse output
-
static
-
class
AuxiliaryDisplay
(config)¶ Bases:
async2v.components.base.SubComponent
Abstract auxiliary display sub-component
This pygame-based auxiliary display can be added the pygame
MainWindow
. It will be rendered next to the main display on the right. In fullscreen mode, the main window then spans the whole virtual display. The physical displays need to be configured accordingly. For this to work, the auxiliary display needs to be provided the resolution of the physical auxliary display. The resolution of the main display can then be determined automatically, as it takes the remaining space of the virtual display.+-----------------+-------------+ | | | | | aux display | | main | | | display +-------------+ | | | | +-----------------+
Parameters: config ( AuxiliaryDisplayConfig
) – Can be generated viaAuxiliaryDisplayConfigurator
-
static
configurator
()¶ Convenience method to create a matching configurator
Return type: AuxiliaryDisplayConfigurator
-
static
-
class
AuxiliaryOpenCvDisplay
(config, source)¶ Bases:
async2v.components.pygame.display.AuxiliaryDisplay
Draw OpenCV frames to the auxiliary display surface.
See
AuxiliaryDisplay
for more information.Frames are scaled without preserving the aspect ratio. This makes it easy to draw on the whole available surface without knowing the target aspect ratio.
Parameters: config ( AuxiliaryDisplayConfig
) – Can be generated viaAuxiliaryDisplayConfigurator
-
class
OpenCvDisplay
(source)¶ Bases:
async2v.components.pygame.display.Display
Pygame display drawing OpenCV frames
Scales OpenCV frames preserving the aspect ratio and draws them on the given surface.
This display returns a
MouseRegion
overlaying the displayed frame with the input frame source as name and the size of the input frame asoriginal_size
.Parameters: source – Key of input event. Needs to provide Frame
events.
-
class
OpenCvMultiDisplay
¶ Bases:
async2v.components.pygame.display.Display
Pygame display drawing OpenCV frames from multiple sources
Scales OpenCV frames preserving the aspect ratio and draws them into a tiled layout. If the number of tiles changes, if the screen size changes or at latest after 60 seconds, the layout is reevaluated and optimized for the best (largest) tile size. All tiles within a layout have the same size.
For each tile, this display returns a
MouseRegion
overlaying the displayed frame with the input frame source as name and the size of the input frame asoriginal_size
.-
frames
¶ Override this property to return a list of OpenCV frames to be rendered.
This list should be stable during one iteration (e.g. directly calculated from the input fields).
Return type: List
[Frame
]
-
after_draw_frame
(frame_index, frame, surface, frame_surface)¶ Override to draw extra information on a single frame
Parameters: Return type: None
-
-
class
OpenCvDebugDisplay
¶ Bases:
async2v.components.pygame.display.OpenCvMultiDisplay
Zero configuration pygame debug display
Renders the latest frames pushed to the key
OPENCV_FRAME_EVENT
by frame source: For each source, a separate tile is created. The builtinVideoSource
automatically pushes to the debug event key.For each tile, this display returns a
MouseRegion
overlaying the displayed frame with the input frame source as name and the size of the input frame asoriginal_size
.