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.SubComponentAbstract pygame display
The pygame
MainWindowsupports multiple displays. The currently selected display is rendered on the main display area. An optionalAuxiliaryDisplaycan 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. Seemousefor details.
-
-
class
AuxiliaryDisplayConfig(resolution)¶ Bases:
objectConfiguration for the
AuxiliaryDisplaycomponent-
resolution= None¶ Type: Tuple[int, int] Resolution (width, height)
-
-
class
AuxiliaryDisplayConfigurator¶ Bases:
async2v.cli.ConfiguratorConfiguration for the
AuxiliaryDisplaycomponent-
static
config_from_args(args)¶ Get configuration from argparse output
-
static
-
class
AuxiliaryDisplay(config)¶ Bases:
async2v.components.base.SubComponentAbstract 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.AuxiliaryDisplayDraw OpenCV frames to the auxiliary display surface.
See
AuxiliaryDisplayfor 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.DisplayPygame display drawing OpenCV frames
Scales OpenCV frames preserving the aspect ratio and draws them on the given surface.
This display returns a
MouseRegionoverlaying 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 Frameevents.
-
class
OpenCvMultiDisplay¶ Bases:
async2v.components.pygame.display.DisplayPygame 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
MouseRegionoverlaying 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.OpenCvMultiDisplayZero configuration pygame debug display
Renders the latest frames pushed to the key
OPENCV_FRAME_EVENTby frame source: For each source, a separate tile is created. The builtinVideoSourceautomatically pushes to the debug event key.For each tile, this display returns a
MouseRegionoverlaying the displayed frame with the input frame source as name and the size of the input frame asoriginal_size.