examples/a121/record_data/with_cli.py

examples/a121/record_data/with_cli.py#

 1# Copyright (c) Acconeer AB, 2022-2023
 2# All rights reserved
 3
 4import acconeer.exptool as et
 5from acconeer.exptool import a121
 6
 7
 8parser = a121.ExampleArgumentParser()
 9parser.add_argument("--output-file", required=True)
10parser.add_argument("--num-frames", required=True, type=int)
11args = parser.parse_args()
12et.utils.config_logging(args)
13
14client = a121.Client.open(**a121.get_client_args(args))
15
16# Session setup, just like the other examples.
17config = a121.SessionConfig()
18client.setup_session(config)
19
20# Here we create and attach a H5Recorder to the Client.
21# The H5Recorder will sample all frames retrieved in the client.
22# Once the "with"-block have been exited, the H5Recorder will
23# wrap up and close the file.
24with a121.H5Recorder(args.output_file, client):
25    client.start_session()
26
27    for i in range(args.num_frames):
28        # Client will send its Results to the H5Recorder.
29        client.get_next()
30        print(f"Result {i + 1}/{args.num_frames} was sampled")
31
32    client.stop_session()
33
34client.close()

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