Calibrate Mode
Purpose
- Calibrate a multi-modal system based on pre-recorded data.
- Visualize the calibration data capture and detection process.
Usage
metrical calibrate [OPTIONS] \
<INPUT_DATA_PATH> \
<PLEX_OR_RESULTS_PATH> \
<OBJECT_SPACE_OR_RESULTS_PATH>
Concepts
The Calibrate command runs a full bundle adjustment over the input calibration data. It requires three main arguments:
- The input data
- An inital plex (usually derived from Init mode). This represents a naive guess at the state of your system.
- An object space file. This tells MetriCal what fiducials, targets, or other features to look for during calibration.
We mean it when we say this runs a full bundle adjustment. MetriCal will optimize both the plex values (the calibration of your system, effectively) and the object space values. This means that MetriCal is robust to bent boards, misplaced targets, etc. All of these values will be solved for during the adjustment, and your calibration results will be all the better for it.
We use ANSI terminal codes for colorizing output according to an internal assessment of metric quality. Generally speaking:
- Cyan: spectacular
- Green: good
- Orange: okay, but generally poor
- Red: bad
Note that these judgements are applied internally to the software and have limits that may change release-to-release. We advise that you determine your own internal limits for each independent metric.
Cached Detections
Extracting detections from a dataset usually takes the lion's share of time during a run. To make this less onerous on subsequent runs, Calibrate mode will automatically create a cache of detections (in JSON format) and save them to the same directory as the input dataset.
Preserving UUIDs for Cached Detections
Detections rely on matching UUIDs between its data and the components in the plex to correctly attribute observations. This means that generating a new Init plex from scratch will require new detections, since the UUIDs will have changed. MetriCal does its best to preserve UUIDs between Init runs by using any previous Init plex as a seed. This allows one to play with different models without having to re-run the detection stage of the calibration.
Motion Filtering
Calibrate and Evaluate modes both run a motion filter over any and all images and point clouds in the input dataset. This filter removes any features that might be affected by motion blur, rolling shutter, false detections, or other artifacts. This is a critical step in the calibration process, as it ensures that the data used for calibration is the best we can get.
There are three states that the motion filter can assign to a component:
- In Motion: The movement between subsequent detections is above the motion threshold for this modality.
- Still: The movement between subsequent detections is below the motion threshold for this modality.
- Still (Redundant): The component is Still and the movement between detections is small enough that they can be considered the same detection.
The motion filter works at the sync group level, not component-by-component. You can see how this decision affects the filter's behavior over time. If one component is moving, the motion filter labels all other components as moving as well, regardless of their actual detected motion status. This decision makes intuitive sense: in a calibration dataset, all components (or all object spaces) should be moving together.
If you have a dataset that is a series of snapshots, rather than continuous motion, you can disable
the motion filter using the --disable-motion-filter
flag.
Image Motion Filtering
The image motion filter is based on the average flow of detected features between subsequent frames. Background motion is not considered, so you can still use this filter when taking data in a busy place.
- Any motion that results in an average pixel shift higher than the camera motion threshold
(
--camera-motion-threshold
) is considered In Motion. The default value for the camera motion threshold is 1 pixel/frame, but this can be adjusted using the flag. - Any motion that results in an average pixel shift lower than the camera motion threshold is considered Still.
- If two frames are both still and the second frame's features have shifted less than 1 pixel on average, the second frame is considered Still (Redundant). These redundant frames add little information to the calibration process and are removed.
Lidar Motion Filtering
The lidar motion filter is based on the movement of the detected center point of a circular markerboard between subsequent observations.
- Any motion that results in the center point moving more than the lidar motion threshold is considered In Motion. The default value for lidar is 0.1m (a pretty generous threshold!).
- Any motion that results in the center point moving less than the lidar motion threshold is considered Still.
- There is no Still (Redundant) state for lidar data.
Extracting Optimized Values from a Results JSON
There is a lot of data in a results JSON output from MetriCal. Luckily, it's all JSON, and it's
fairly easy to pick apart. Use jq
to extract this data into its
own file for easy analysis and comparison to the original inputs.
Install jq using apt:
sudo apt install jq
Then use jq to extract the relevant optimized data.
jq .plex results.json > optimized_plex.json
jq .object_space results.json > optimized_obj.json
Examples
Run a calibration
metrical calibrate \
--output-json results.json \
$DATA $PLEX $OBJSPC
Visualize detections
Make sure you have a Rerun server running!
metrical calibrate \
--render \
--output-json results.json \
$DATA $PLEX $OBJSPC
Remap topics to different components in a plex
With the
--topic-to-component
flag, you can map topics to component names or UUIDs in the input plex. This prevents laborious hand-tuning of a plex JSON whenever a dataset is recorded with a different topic name.For example, if we called our folder
camera_1
and that corresponded to some component namedir_SN5XXX
in the plex, then we could do the following:metrical calibrate \
--topic-to-component camera_1:ir_SN5XXX \ # our corrected topic-component relation
--output-json results.json \ # the output file
$DATA $PLEX $OBJSPC
Save calibration log output
Log output from the program is output on
stderr
. If you want to record this for later, you can actually save a log by using the--report-path
flag. This will save a .log file and, if possible, a HTML version of the log as well.metrical calibrate --report-path metrical.log $DATA $PLEX $OBJSPC
Disable the motion filter for motion-heavy datasets
By default, MetriCal will run a motion filter over the input dataset and remove observations with too much motion, i.e. where it appears that relative motion was too large. For observation streams with inconsistent or infrequent observations, this can result in filtering everything! It can also be a sign of malformed timestamps.
Filtering is recommended when running a dataset with generally quick observation frequencies (>15Hz) and consistent timestamps. Otherwise, you should disable the filter with the
--disable-motion-filter
flag.metrical calibrate --disable-motion-filter $DATA $PLEX $OBJSPC
Arguments
[INPUT_DATA_OR_DETECTIONS_PATH]
The dataset with which to calibrate, or the detections from an earlier run. Users can pass:
- ROS1 bags, in the form of a
.bag
file.- MCAP files, with an
.mcap
extension.- A top-level directory containing a set of nested directories for each topic.
- A detections JSON with all the cached detections from a previous run.
In all cases, the topic/folder name must match a named component in the plex in order to be matched correctly. If this is not the case, there's no need to edit the plex directly; instead, one may use the
--topic_to_component
flag.
[PLEX_OR_RESULTS_PATH]
The path to the input plex. This can be a MetriCal results JSON or a plex JSON.
[OBJECT_SPACE_OR_RESULTS_PATH]
A path pointing to a description of the object space for the adjustment. This can be a MetriCal results JSON or an object space JSON.
Options
Universal Options
As with every mode, all universal options are supported (though not all may be used).
-y, --overwrite-detections
Overwrite the detections at this location, if they exist.