examples/a121/algo/breathing/breathing.py#
1# Copyright (c) Acconeer AB, 2022-2023
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.breathing import RefApp
9from acconeer.exptool.a121.algo.breathing._ref_app import (
10 BreathingProcessorConfig,
11 RefAppConfig,
12 get_sensor_config,
13)
14from acconeer.exptool.a121.algo.presence import ProcessorConfig as PresenceProcessorConfig
15
16
17def main():
18 args = a121.ExampleArgumentParser().parse_args()
19 et.utils.config_logging(args)
20
21 # Setup the configurations
22 # Detailed at https://docs.acconeer.com/en/latest/exploration_tool/algo/a121/ref_apps/breathing.html
23
24 # Sensor selections
25 sensor = 1
26
27 # Ref App Configurations
28 breathing_processor_config = BreathingProcessorConfig(
29 lowest_breathing_rate=6,
30 highest_breathing_rate=60,
31 time_series_length_s=20,
32 )
33
34 # Presence Configurations
35 presence_config = PresenceProcessorConfig(
36 intra_detection_threshold=4,
37 intra_frame_time_const=0.15,
38 inter_frame_fast_cutoff=20,
39 inter_frame_slow_cutoff=0.2,
40 inter_frame_deviation_time_const=0.5,
41 )
42
43 # Breathing Configurations
44 ref_app_config = RefAppConfig(
45 use_presence_processor=True,
46 num_distances_to_analyze=3,
47 distance_determination_duration=5,
48 breathing_config=breathing_processor_config,
49 presence_config=presence_config,
50 )
51
52 # End setup configurations
53
54 # Preparation for client
55 sensor_config = get_sensor_config(ref_app_config=ref_app_config)
56 client = a121.Client.open(**a121.get_client_args(args))
57 client.setup_session(sensor_config)
58
59 # Preparation for reference application processor
60 ref_app = RefApp(client=client, sensor_id=sensor, ref_app_config=ref_app_config)
61 ref_app.start()
62
63 interrupt_handler = et.utils.ExampleInterruptHandler()
64 print("Press Ctrl-C to end session")
65
66 while not interrupt_handler.got_signal:
67 processed_data = ref_app.get_next()
68 try:
69 print("Breathing result " + str(processed_data.breathing_result))
70 except et.PGProccessDiedException:
71 break
72
73 ref_app.stop()
74 print("Disconnecting...")
75 client.close()
76
77
78if __name__ == "__main__":
79 main()
View this example on GitHub: acconeer/acconeer-python-exploration