examples/a121/algo/hand_motion/hand_motion_example_app.py

examples/a121/algo/hand_motion/hand_motion_example_app.py#

 1# Copyright (c) Acconeer AB, 2023-2024
 2# All rights reserved
 3
 4from __future__ import annotations
 5
 6import acconeer.exptool as et
 7from acconeer.exptool import a121
 8from acconeer.exptool.a121.algo.hand_motion import (
 9    AppMode,
10    DetectionState,
11    ModeHandler,
12    ModeHandlerConfig,
13)
14
15
16sensor_id = 1
17
18
19def main():
20    client = a121.Client.open()
21
22    config = ModeHandlerConfig()
23
24    aggregator = ModeHandler(
25        client=client,
26        sensor_id=sensor_id,
27        mode_handler_config=config,
28    )
29
30    aggregator.start()
31
32    interrupt_handler = et.utils.ExampleInterruptHandler()
33    print("Press Ctrl-C to end session")
34
35    while not interrupt_handler.got_signal:
36        result = aggregator.get_next()
37
38        if result.app_mode == AppMode.PRESENCE:
39            print("No presence detected")
40        elif result.app_mode == AppMode.HANDMOTION:
41            if result.example_app_result.detection_state == DetectionState.NO_DETECTION:
42                print("No hand motion detected")
43            elif result.example_app_result.detection_state == DetectionState.RETENTION:
44                print("Retaining detection")
45            elif result.example_app_result.detection_state == DetectionState.DETECTION:
46                print("Hand motion detected")
47            else:
48                msg = "Invalid detection state"
49                raise RuntimeError(msg)
50
51    print("Disconnecting...")
52
53
54if __name__ == "__main__":
55    main()

View this example on GitHub: acconeer/acconeer-python-exploration