Spaces:
Sleeping
Sleeping
| """Reader modules for extracting values from video frame regions. | |
| This package contains components that read values from detected regions: | |
| - Play clock digit values (via template matching) | |
| - FLAG indicator (via yellow color detection) | |
| - Future: expanded timeout value reading | |
| Note: detect_red_digits and normalize_to_grayscale are now in utils.color | |
| """ | |
| from typing import Optional, Protocol | |
| from .models import ( | |
| FlagReading, | |
| PlayClockReading, | |
| TemplateMatchResult, | |
| TemplatePlayClockReading, | |
| ) | |
| from .flags import FlagReader | |
| from .playclock import ReadPlayClock | |
| class FlagConfig(Protocol): # pylint: disable=too-few-public-methods | |
| """Protocol for objects providing FLAG region configuration.""" | |
| flag_x_offset: int | |
| flag_y_offset: int | |
| flag_width: int | |
| flag_height: int | |
| def create_flag_reader(config: FlagConfig) -> Optional[FlagReader]: | |
| """ | |
| Create a FlagReader from a configuration object. | |
| Factory function to reduce duplicate FlagReader initialization code. | |
| Returns None if FLAG region is not configured (width or height is 0). | |
| Args: | |
| config: Object with flag_x_offset, flag_y_offset, flag_width, flag_height attributes | |
| Returns: | |
| FlagReader if configured, None otherwise | |
| """ | |
| if config.flag_width > 0 and config.flag_height > 0: | |
| return FlagReader( | |
| flag_x_offset=config.flag_x_offset, | |
| flag_y_offset=config.flag_y_offset, | |
| flag_width=config.flag_width, | |
| flag_height=config.flag_height, | |
| ) | |
| return None | |
| __all__ = [ | |
| # Models | |
| "FlagReading", | |
| "PlayClockReading", | |
| "TemplateMatchResult", | |
| "TemplatePlayClockReading", | |
| # FLAG reading | |
| "FlagReader", | |
| "create_flag_reader", | |
| # Play clock reading | |
| "ReadPlayClock", | |
| ] | |