Ejemplo n.º 1
0
    def __init__(self, input_key: str, output_key: str):
        self.input: Latest[Frame] = Latest(key=input_key, trigger=True)
        self.keyboard: Buffer[KeyboardEvent] = Buffer(key=EventBasedKeyboardHandler.KEYBOARD_EVENT)
        self.output: Output[Frame] = Output(key=output_key)
        self.debug_output: Output[Frame] = Output(key=OPENCV_FRAME_EVENT)

        self._horizontal_flip_enabled = True
        self._vertical_flip_enabled = False
Ejemplo n.º 2
0
 def __init__(self, layout: KeyboardLayout):
     """
     :param layout: Use layout created by the `layout_from_args` method of the `KeyboardConfigurator` created for
         that concrete `KeyboardHandler`
     """
     super().__init__(layout)
     self.keyboard = Output(self.KEYBOARD_EVENT)
     self.text = Output(self.KEYBOARD_EVENT)
     self.capture_trigger = Latest(self.CAPTURE_TEXT_TRIGGER)
Ejemplo n.º 3
0
    def __init__(self, game):
        self.game = game
        self.node = 'start'
        self.selection = 0

        self.keyboard = Buffer(EventBasedKeyboardHandler.KEYBOARD_EVENT,
                               trigger=True)  # type: Buffer[KeyboardEvent]

        self.text = Output('text')
        self.choices = Output('choices')
Ejemplo n.º 4
0
 def __init__(self):
     self.source = Latest('source', trigger=True)  # type: Latest[Frame]
     self.people = Latest('people')  # type: Latest[List[Person]]
     self.output = Output('display')
     self.debug = Output(event.OPENCV_FRAME_EVENT)
     self.mouse = Buffer(
         EventBasedMouseHandler.MOUSE_EVENT)  # type: Buffer[MouseEvent]
     self.mouse_move = LatestBy(
         EventBasedMouseHandler.MOUSE_MOVEMENT,
         lambda m: m.region.name)  # type: LatestBy[MouseMovement]
Ejemplo n.º 5
0
 def __init__(self):
     self.source = Latest('source', trigger=True)  # type: Latest[Frame]
     self.output = Output('display')
     self.overlay = Output('overlay')
     self.mouse_movement = Buffer(
         EventBasedMouseHandler.MOUSE_MOVEMENT,
         trigger=True)  # type: Buffer[MouseMovement]
     self.clear_canvas = Latest('trigger.clear_canvas', trigger=True)
     self.debug = Output(event.OPENCV_FRAME_EVENT)
     self._canvas = None
     self._last_position = None
Ejemplo n.º 6
0
 def __init__(self, config: VideoSourceConfig, key: str = 'source'):
     """
     :param config: Can be generated via `VideoSourceConfigurator`
     :param key: Event key of video output
     """
     self._path = config.path
     self._target_fps = config.fps
     self.output = Output(key)
     self.debug_output = Output(event.OPENCV_FRAME_EVENT)
     self._executor = ThreadPoolExecutor(max_workers=1)
     self._resolution = config.resolution
     self._resolution_verified = False
     self._capture: cv2.VideoCapture = None
Ejemplo n.º 7
0
 def __init__(self, source, projector, debug):
     self._background: cv2.BackgroundSubtractor = cv2.createBackgroundSubtractorMOG2(
     )
     self._calibration_cycle_i = 0
     self._initialize_pattern()
     self.source: Latest[Frame] = Latest(source, trigger=True)
     self.projector = Output(projector)
     if debug:
         self.debug = Output(event.OPENCV_FRAME_EVENT)
     else:
         self.debug = None
     self._last_calibrated = 0
     self._transformation_matrix = None
Ejemplo n.º 8
0
    def __init__(self, source):
        super().__init__(source)
        self.mouse_event: Buffer[MouseEvent] = Buffer(
            EventBasedMouseHandler.MOUSE_EVENT)
        self.reset_calibration = Output(
            ProjectorDriver2d.RESET_CALIBRATION_TRIGGER)
        self.clear_canvas = Output('trigger.clear_canvas')

        self._menu = Menu([
            Label('Menu'),
            Button('Calibrate', self.calibrate),
            Button('Clear Canvas', self.clear),
        ],
                          position=(1, 0))
Ejemplo n.º 9
0
 def __new__(cls, *args, **kwargs):
     if cls.__name__ not in cls.__count:
         cls.__count[cls.__name__] = 0
     __instance = super().__new__(cls)
     __instance._numeric_id = cls.__count[cls.__name__]
     __instance.logger = logwood.get_logger(__instance.id)
     __instance.__shutdown = Output(SHUTDOWN_EVENT)
     cls.__count[cls.__name__] += 1
     return __instance
Ejemplo n.º 10
0
 def __init__(
     self,
     source: str,
     overlay: str,
     projector: str = 'projector',
     config: ProjectorDriver2dConfiguration = ProjectorDriver2dConfiguration(
     )):
     """
     :param source: Key of the video stream input. Needs to provide events with `Frame` payload.
     :param overlay: Key of the overlay input. Needs to provide events with `Frame` payload.
     :param projector: Key of projector output. `Frame` events are pushed to this output.
     :param config: Can be generated via `ProjectorDriver2dConfigurator`
     """
     self._calibrator = _ProjectorCalibrator2d(source, projector,
                                               config.debug)
     super().__init__([self._calibrator])
     self.overlay: Latest[Frame] = Latest(overlay, trigger=True)
     self.projector = Output(projector)
     self.reset = Latest(self.RESET_CALIBRATION_TRIGGER, trigger=True)
     self._calibration_started = False
Ejemplo n.º 11
0
 def __init__(self):
     self.output = Output('sample')
Ejemplo n.º 12
0
 def __init__(self, input_key: str, output_key: str):
     self.input: Latest[Frame] = Latest(key=input_key, trigger=True)
     self.output: Output[Frame] = Output(key=output_key)
     self.debug_output: Output[Frame] = Output(key=OPENCV_FRAME_EVENT)
     self.hog = cv2.HOGDescriptor()
     self.hog.setSVMDetector(cv2.HOGDescriptor_getDefaultPeopleDetector())
Ejemplo n.º 13
0
 def __init__(self, input_, output):
     self.input = Latest(input_, trigger=True)
     self.output = Output(output)
Ejemplo n.º 14
0
 def __init__(self) -> None:
     super().__init__()
     self.output = Output('trigger')
Ejemplo n.º 15
0
 def __init__(self, input_key: str, output_key: str):
     self.input: Latest[Frame] = Latest(key=input_key, trigger=True)
     self.output: Output[Frame] = Output(key=output_key)
     self.debug_output: Output[Frame] = Output(key=OPENCV_FRAME_EVENT)
Ejemplo n.º 16
0
 def __init__(self):
     self.input: Latest[Frame] = Latest(key='source', trigger=True)
     self.debug_output: Output[Frame] = Output(key=OPENCV_FRAME_EVENT)
Ejemplo n.º 17
0
 def __init__(self, in_key, out_key):
     self.input: Latest[Frame] = Latest(in_key, trigger=True)
     self.output: Output[Frame] = Output(out_key)
 def __init__(self):
     self.item_source = Buffer('item_source', trigger=True)
     self.label = Latest('label')
     self.output = Output('sink')
Ejemplo n.º 19
0
 def __init__(self):
     self._regions: List[MouseRegion] = []
     self.event = Output(self.MOUSE_EVENT)
     self.movement = Output(self.MOUSE_MOVEMENT)
     self._last_region: MouseRegion = None
     self._last_position = (-1, -1)
Ejemplo n.º 20
0
 def __init__(self, layout: KeyboardLayout):
     super().__init__(layout)
     self.state = Output('state')
     self.name = Output('name')
     self._name = 'World'
Ejemplo n.º 21
0
 def __init__(self):
     self.source: Latest[Frame] = Latest('source', trigger=True)
     self.faces = Latest('faces')
     self.output: Output[Frame] = Output('terminator')
     self.debug_output: Output[Frame] = Output(OPENCV_FRAME_EVENT)
 def __init__(self, data, name='sample'):
     self.output = Output(name)
     self.data = data.copy()
Ejemplo n.º 23
0
 def __init__(self):
     self.input = Buffer('sample', trigger=True)
     self.output = Output('sample')
     self.log = []
Ejemplo n.º 24
0
 def __init__(self):
     self.source = Latest('source', trigger=True)  # type: Latest[Frame]
     self._hog = cv2.HOGDescriptor()
     self._hog.setSVMDetector(cv2.HOGDescriptor_getDefaultPeopleDetector())
     self.output = Output('people')
 def __init__(self, input_, output):
     self.input = Latest(input_)
     self.output = Output(output)
 def __init__(self):
     self.output = Output('item_source')
Ejemplo n.º 27
0
 def __init__(self):
     self.source: Latest[Frame] = Latest('source', trigger=True)
     self.face_cascade = cv2.CascadeClassifier(self.FACE_CASCADE)
     self.output = Output('faces')
 def __init__(self):
     self.output = Output('label')