Skip to main content

File Reader Headers Example

Basic Knowledge Requirements

Before diving into this example, here's a quick overview of what you'll need to be familiar with:

  1. Python Programming: This code is written in Python. Basic constructs such as functions, conditional statements, loops, and more are utilized.

This File Reader Headers example:

  1. Parses a recorded *.bin log file and prints all topics, with a count of that topic's logged messages
  2. Prints all messages with /header in the uri path
    • Typically you would expect to see metadata & oak camera calibrations here

You can either run this example directly on a brain by ssh'ing in, or use your local PC.

1. Obtain a log file

Record your own

See the Recorder App Guide for instructions.

2. Install the farm-ng Brain ADK package

3. Install the example's dependencies

Setup

cd farm-ng-amiga/
Recommended

Create a virtual environment

python3 -m venv venv
source venv/bin/activate

Install

cd py/examples/file_reader_headers
pip install -r requirements.txt

4. Execute the Python script

Specify the log file, e.g.:

python main.py --file-name <path-to-file>/2023_01_23_45_54_32_101010_element-vegetable.0000.bin

Additional args

Use the --help flag to see all possible arguments for using this tool.

# usage: Event file reader example for parsing header messages. [-h] --file-name FILE_NAME [--skip-calibrations]

# optional arguments:
# -h, --help show this help message and exit
# --file-name FILE_NAME
# Path to the `events.bin` file.
# --skip-calibrations Skip camera calibration header messages.

For instance, you can skip printing the camera calibrations if you only want to see the other headers (e.g. metadata you specified when recording).