Using the sample scripts

This sections decribes how to use the different scripts to achieve your goals.

Sample Scripts

🚧

The samples will become a Python SDK soon

At this point in time the Aivero Python Interface is a collection of python scripts meant to be an example for further development by you, the user.

In the near future we will start converting them into a more classical Python SDK.

Until then it may be required to edit the python scripts to achieve the intended outcome. Read carefully.

In most of the scripts do not forget to indicate which streams you want to operate on:

  • -i1 for infra stream
  • -i2 for second infra stream
  • -c for color stream
  • -d for depth stream

Stream Preview

If you want to preview a local 3DQ encoded file you can use the preview_3dq_sample.py script:

./scripts/preview_3dq_sample.py $FILEPATH -c -i1

During playback you can press "Space" to pause the preview and "Enter" to resume.
You can also seek the file using the arrow keys: to jump forwards use the "Right" key, to jump backwards use the "Left" key and to jump to the start use the "Up" key.
Furthermore, you can step the file frame by frame, by pausing it using the "Space" key and pressing the "S" key to step one frame.
If you wish to change the playback rate you can do that by pressing the "2" key for double speed, or "1" key for normal playback.

Write file frames to TIFF

If you would like to write a single file frames to the TIFF format you can run our write_to_tiff_frames.py sample.

To do so please run:

./scripts/write_to_tiff_frames.py $FILEPATH $OUTPUT_FOLDER/file-%05d.tiff -d -i1

The sample will write the selected stream frames to the output_folder and will append the stream name and frame number before the .tiff extension (e.g. file-00594.infra1.tiff). The output folder will be created if it does not exist.

Write synchronized session frames to TIFF

If you would like to write session files frames to the TIFF format synchronized by acquisition time, you can run our write_session_to_tiff_frames.py sample.

To do so please run:

./scripts/write_session_to_tiff.py --session $RECORDING_SESSION_FOLDER --output_filename $OUTPUT_FOLDER -d -i1

The sample will write the selected stream frames to the OUTPUT_FOLDER and will append the stream name, camera name and frame number before the .tiff extension (e.g. file-00594.camera1.infra1.tiff). The output folder will be created if it does not exist.

📘

TIFF is a lossless format. This means this sample works for all Aivero supported streams but it may take some time. Monitor the output folder to check progress.

Convert non-depth streams to MP4

If you are interested in obtaining the non-depth streams from a 3DQ encoded file you can use the "convert_to_mp4.py" sample to convert those streams to individual mp4 files to the APyI directory.

To do so please run:

./scripts/convert_to_mp4.py $FILEPATH -c -i1

Alternatively, you can set which streams you would lie to write to mp4 in the stream_config variable in convert_to_mp4.py

Join split files

One can also join Aivero's DeepServer split files into a single monolithic file using the Aivero Python Interface. This only makes sense if you input a glob representing split files as the $FILEPATH (e.g. /home/user/file-*.mkv), but you could also use this sample to remove streams from your current file by not passing all of the stream config flags.

In order to run the sample just do:

./scripts/join_split_files.py $FILEPATH $OUTPUT_FILENAME -d -i1

Compute depth pixel 3D coordinate

If you want to see how to get 3D coordinates from a file containing a depth stream you can run:

./scripts/pixel_to_3d_sample.py $FILEPATH -c -i1

Please have a look at pixel_to_3d_sample.py for more details.

Push to callback function

This sample allows you to write your callback for each frame as fast as possible. The current sample writes all frames to PNG files.

./scripts/push_sample.py $FILEPATH -c -i1

Please have a look at push_sample.py for more details.

Pull to callback function

This sample like the push sample allows you to write your callback for each frame. However this allows you to pull samples one by one at the user's desired rate.

./scripts/pull_sample.py $FILEPATH -c -i1

Please have a look at pull_sample.py for more details.

Download files from Google Cloud Storage

If you store your recording in a Google Cloud Storage bucket and wish to work with the files loally, you can retrieve them using the download_from_gcs.py script.

The script expects the following parameters:

  • --gcs_bucket (required): The name of the GCS bucket to retrieve data from.
  • --gcs_folder (requried): The path to the folder in the GCS bucket.
  • --service_account (required): Path to a GCP service account that will be used to download the files.
  • --local_folder (optional): The path to the folder to save the files to. If unspecified, the name of the folder in GCS will be user. If non-existent, the script will create it.

An example run could then look as follows:

./scripts/download_from_gcs.py --gcs_bucket test_bucket --gcs_folder recording_session_1 --service_account service_account.json