Using the sample scripts
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.
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 frames to TIFF
If you would like to write all of you 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.
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/push_sample.py $FILEPATH -c -i1
Please have a look at push_sample.py
for more details.
If you would like to write all of you 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.
Updated 8 months ago