|
1 | 1 | # python-recorder |
2 | 2 |
|
3 | | -Visual and Acoustic Odometry recorder using python. Devices: RealSense D435i |
4 | | -camera, RODE VideoMicNTG and smartLav+ microphones |
5 | | - |
6 | | -Framework |
7 | | - |
8 | | -TODO ros |
| 3 | +Device independent framework for synchronized recording. Originally designed to |
| 4 | +record audio and video from a Realsense camera and several microphones. This |
| 5 | +framework is designed for researchers collecting multimodal datasets. It |
| 6 | +provides an easy command line application which allows to configure, test and |
| 7 | +use the available sensors in the host machine. The framework can be divided in |
| 8 | +two main features: |
| 9 | + |
| 10 | +## Devices |
| 11 | +They provide a common interface to initialize, `start` and `stop` a recording, |
| 12 | +whether is a camera, a microphone or any other sensor. When the recording is |
| 13 | +stopped, device parameters (e.g., `samplerate` in microphones, `framerate` in |
| 14 | +cameras) as well as a `start_timestamp` and an `end_timestamp` are saved |
| 15 | +together with the recorded data which allows fine synchronization of data from |
| 16 | +multiple devices in post-processing. |
| 17 | + |
| 18 | +Devices are configurable through a command line application, which searches for |
| 19 | +available options in the host machine. At the same time, they are saved in a |
| 20 | +[`yaml` formatted text file](./example-config.yaml). Which allows easy access |
| 21 | +to device exclusive configuration parameters. |
| 22 | + |
| 23 | +Multiple devices compose a [`Recorder` object](./recorder/recorder.py), which |
| 24 | +is responsible for initializing all its devices, setup an output folder for the |
| 25 | +recordings, and start and stop the recording. |
| 26 | + |
| 27 | +Adding new devices classes is simple, one just needs to extend the [`Device` |
| 28 | +class](./recorder/device/device.py) and override its abstract methods (`find`, |
| 29 | +`_start`, `_stop` and `show_results`). |
9 | 30 |
|
10 | 31 | ## Listeners |
11 | | -`listen` command does not setup the recorder. The listener is responsible of |
12 | | -setting up the recorder as it sees fit. In the case of the `localhost` |
13 | | -listener, a `GET` request to the `/setup` endpoint is necessary before trying |
14 | | -to start the recording via the `/start` endpoint. |
| 32 | +Researchers usually want to synchronize the recording with a specific event, a |
| 33 | +test or experiment, which can be triggered by a different machine. A `Listener` |
| 34 | +is an interface between a `Recorder` and an external event. At the moment, the |
| 35 | +only one available is a [`Localhost` |
| 36 | +listener](./recorder/listener/localhost.py). Which triggers the recording |
| 37 | +according to `GET` requests through the local network. But additional listeners |
| 38 | +can be added by extending the [`Listener` |
| 39 | +class](./recorder/listener/listener.py) and overriding its abstract methods. An |
| 40 | +example of another listener would be a `ROS` node that subscribes to a specific |
| 41 | +topic and triggers the recording according to a specific set of messages. |
| 42 | + |
| 43 | +Listeners can be setup through the `listen`. This command does not initialize |
| 44 | +the devices. The listener is responsible of executing `recorder.setup()` as it |
| 45 | +sees fit. In the case of the `localhost` listener, a `GET` request to the |
| 46 | +`/setup` endpoint is necessary before trying to start the recording via the |
| 47 | +`/start` endpoint. |
15 | 48 |
|
16 | 49 | # Setup |
| 50 | +It is recommended to use a virtual environment in order to isolate the |
| 51 | +installation, as it provides a command line interface named `recorder` that can |
| 52 | +conflict with other system packages. |
17 | 53 |
|
18 | | -Clone this repository to your local machine. Detailed instructions about |
19 | | -cloning repositories and installing python dependencies can be found |
20 | | -[here](https://docs.google.com/document/d/15Mj3x9Im7Yfz3sPo5f4dUjQZgabjVtIL2RBHvM2798E/edit?usp=sharing). |
21 | | - |
22 | | -## Install Python (3.5 - 3.9) |
23 | | -Do not install the latest version of Python (currently 3.10) as it is not |
24 | | -compatible with Intel RealSense SDK yet. |
25 | | - |
26 | | -https://www.python.org/downloads/ |
27 | | - |
28 | | -## Install Intel RealSense SDK 2.0 |
29 | | - |
30 | | -https://github.com/IntelRealSense/librealsense/releases |
31 | | - |
32 | | -## Install dependencies |
33 | | -Open a terminal in the directory where this file is located. Then create a |
34 | | -virtual environment: |
35 | 54 | ``` |
36 | 55 | python -m venv venv |
37 | | -``` |
| 56 | +```` |
38 | 57 |
|
39 | 58 | Activate the environment on Windows: |
| 59 | +
|
40 | 60 | ``` |
41 | 61 | venv\Scripts\activate |
42 | 62 | ``` |
| 63 | +
|
43 | 64 | or on MacOS and Linux: |
| 65 | +
|
44 | 66 | ``` |
45 | 67 | source venv/bin/activate |
46 | 68 | ``` |
47 | 69 |
|
48 | | -Finally, install dependencies with pip: |
| 70 | +Install from [Pypi](https://pypi.org/project/python-recorder/). There are |
| 71 | +optional dependencies that define which devices and listeners are available, |
| 72 | +due to the fact some of these dependencies are not available for all operative |
| 73 | +systems. Check [extras](#extras) for more information about it. |
| 74 | +``` |
| 75 | +pip install python-recorder[all] |
| 76 | +``` |
| 77 | +
|
| 78 | +or install this repository to use the latest development versions. |
49 | 79 | ``` |
50 | | -pip install -r requirements.txt |
| 80 | +pip install git+https://github.com/AcousticOdometry/python-recorder.git[all] |
51 | 81 | ``` |
52 | 82 |
|
| 83 | +## Extras |
| 84 | +Extras can be installed through [the `pip install` |
| 85 | +command](https://pip.pypa.io/en/stable/cli/pip_install/#requirement-specifiers) |
| 86 | +by specifying them at the end of the package name: |
| 87 | +
|
| 88 | +``` |
| 89 | +pip install python-recorder[extra_one,extra_two] |
| 90 | +``` |
| 91 | +
|
| 92 | +The available extras are defined in [`pyproject.toml`](./pyproject.toml) and |
| 93 | +are described here: |
| 94 | +
|
| 95 | +- `realsense`: [Intel |
| 96 | + Realsense](https://www.intel.com/content/www/us/en/architecture-and-technology/realsense-overview.html) |
| 97 | + devices depend on [pyrealsense2](https://pypi.org/project/pyrealsense2/). |
| 98 | +- `all`: All the extras defined above. |
| 99 | +
|
53 | 100 | # Usage |
54 | 101 | Check the usage with the `--help` option: |
55 | 102 | ``` |
56 | | -python vao-recorder.py --help |
| 103 | +recorder --help |
57 | 104 | ``` |
58 | 105 |
|
59 | 106 | # Workflow |
60 | 107 |
|
61 | 108 | Configure the devices to be used. One can always modify the configuration |
62 | 109 | manually in the generated `yaml` file. |
63 | 110 | ``` |
64 | | -python vao-recorder.py config |
| 111 | +recoder config |
65 | 112 | ``` |
66 | 113 |
|
67 | 114 | Test that the chosen audio devices are working |
68 | 115 | ``` |
69 | | -python vao-recorder.py test microphone |
| 116 | +recorder test microphone |
70 | 117 | ``` |
71 | 118 |
|
72 | 119 | Record an experiment with the configured devices |
73 | 120 | ``` |
74 | | -python vao-recorder.py record |
75 | | -``` |
| 121 | +recorder record |
| 122 | +``` |
| 123 | +
|
| 124 | +Listen to `GET` requests through the local network |
| 125 | +``` |
| 126 | +recorder listen localhost |
| 127 | +``` |
| 128 | +
|
| 129 | +# Contributing |
| 130 | +We are open to contributions. Please, feel free to open an issue or pull |
| 131 | +request with any improvement or bug report. The framework is simple and easily |
| 132 | +extensible, it should fit easily in many projects. |
| 133 | +
|
| 134 | +## TODO |
| 135 | +
|
| 136 | +- [ ] ROS listener |
| 137 | +- [ ] Complete test suite |
| 138 | +- [ ] Camera device with `OpenCV` |
| 139 | +- [ ] Speedup the configuration file creation with compiled code? |
0 commit comments