Skip to content

Pose-Based Calibration

Pose-based calibration is a scripting alternative to board-based calibration. The standard workflow uses a board or marker with identifiable corners and known dimensions. Here, a pose tracker identifies matching body keypoints across synchronized camera views to estimate each camera's relative position and orientation. Watch the video walkthrough for a visual overview of the pipeline.

Without a calibration board of known size, the result needs a separate scale measurement and coordinate frame. The example below scales the rig to the subject's height using summed body-segment lengths, estimates vertical from each camera's video with GeoCalib (bundled as ONNX, requiring nothing beyond the [tracking] extra), and sets the floor at the lowest reconstructed 3D point. If you have a measured distance between two cameras instead of the subject's height, you can pass CameraDistance to volume.scaled(...). The example then centers the origin between the cameras.

Validation

In a nine-camera BioCV benchmark from one straight-line walk, pose-based calibration preserved joint angles closely (0.18° median RMS) but shifted positions along the walkway (14.3 mm median RMS). See Validation for the full benchmark setup and results.

Try the runnable demo

To run this workflow end to end on public data without preparing your own videos, install the tracking extra and run:

caliscope demo

Or run it directly with uvx without a local checkout:

uvx --from "caliscope[tracking]" caliscope demo

The command downloads Pose2Sim's four-camera Demo_SinglePerson recording, its Qualisys reference calibration, and the required ONNX models on first run. It then runs the pose-based calibration pipeline, prints the accuracy report, and opens a synced 3D and video viewer in your browser (Three.js loads from a CDN). Pass --no-serve to export the playback bundle and exit without starting the local server.

Install

The workflow runs from Python and requires pose tracking:

uv pip install "caliscope[tracking]"

Prepare the recording

You need calibrated intrinsics for every camera. Follow the intrinsic-calibration scripting workflow to create the camera-array TOML.

Record one calibration subject walking through the shared capture space. Camera views must overlap through enough of the motion to connect the rig. Other people can be visible, but the intended subject's bounding boxes must cover the most image area in each camera, counting each pixel once.

The example first detects people and links their boxes into camera-local tracks. It drops boxes near the image edge, keeps the track whose boxes cover the most image area in each camera, and estimates keypoints only in those boxes. Track IDs are local to each camera. Calibration relies on the recording protocol to select the same person across views, because matching people across cameras needs the camera poses this workflow produces. Once the cameras are calibrated, cross-camera track association links every person's tracks across the rig.

exclude_edge_boxes(margin_px=24) drops any detection whose bounding box comes within margin_px original image pixels of any frame border. When a person walks into or out of view and gets clipped by the image edge, pose estimators can place off-frame joints along the border, where lens distortion is also largest. Dropping border-clipped boxes keeps those biased keypoints out of calibration. The default 24 pixels works well for standard 1080p framing. Lower margin_px (or pass 0) if a camera frames the subject tightly near the top or bottom edge, or during post-calibration reconstruction when you want to keep tracking close to the border. The generic extract_image_points_multicam entry point remains available; with a detector-backed ONNX tracker, it chooses the largest box independently in each frame.

Each video needs the same camera ID it had during intrinsic calibration. Choose the alignment policy by building a SynchronizedTimestamps object and passing it to track_objects_and_keypoints (or track_objects). SynchronizedTimestamps.from_anchor_frames takes one frame per camera known to show the same instant, and assumes each camera has a constant frame interval. SynchronizedTimestamps.from_csv_path uses per-frame timestamps, and SynchronizedTimestamps.from_video_paths assumes the videos start and stop together. The tracking workflow does not infer timing offsets from body motion. The generic multicamera extraction workflow still supports timestamp-based synchronization.

Record the calibration subject's height in meters (or measure the distance between two cameras in meters) to set metric scale.

For sideways videos, pass rotation_counts to track_objects_and_keypoints (or track_objects), for example rotation_counts={2: 1} to turn camera 2 by one quarter turn for tracking. Saved boxes record the rotation for the keypoint pass; both boxes and keypoints return in the original image coordinates.

Run the calibration

Edit the paths, camera IDs, and subject height in this script. The camera-array TOML must contain the intrinsic matrices and distortion coefficients from your intrinsic calibration.

from importlib.resources import files
from pathlib import Path

from caliscope import MODELS_DIR
from caliscope.api import (
    CameraArray,
    calibrate_extrinsics,
    estimate_vertical,
    track_objects_and_keypoints,
)
from caliscope.recording.synchronized_timestamps import SynchronizedTimestamps
from caliscope.reporting import print_extrinsic_report
from caliscope.trackers.model_card import ModelCard
from caliscope.trackers.model_download import download_and_extract_model
from caliscope.trackers.onnx_tracker import OnnxTracker

# Change these paths, camera IDs, and stature to match your recording.
CAMERA_ARRAY_TOML = Path("intrinsics/camera_array.toml")
VIDEOS = {
    0: Path("markerless/cam_0.mp4"),
    1: Path("markerless/cam_1.mp4"),
    2: Path("markerless/cam_2.mp4"),
}
SUBJECT_HEIGHT_M = 1.70
OUTPUT_DIR = Path("markerless_capture_volume")

# Load the packaged RTMPose-l Halpe26 card without starting the GUI.
card_path = Path(str(files("caliscope.trackers.model_cards"))) / "rtmpose_l_halpe26.toml"
card = ModelCard.from_toml(card_path, models_dir=MODELS_DIR)
if not card.onnx_exists:
    download_and_extract_model(card, MODELS_DIR)
if not card.detector.onnx_exists:
    download_and_extract_model(card.detector, MODELS_DIR)
tracker = OnnxTracker(card)

# Detect, track, and estimate keypoints in one pass over the videos.
# Drop border-clipped boxes (24 px default), keep the primary person, and select their keypoints in memory.
cameras = CameraArray.from_toml(CAMERA_ARRAY_TOML)
timestamps = SynchronizedTimestamps.from_anchor_frames(VIDEOS, {cam_id: 0 for cam_id in VIDEOS})
box_tracks, all_points = track_objects_and_keypoints(
    VIDEOS,
    tracker.detector,
    tracker,
    timestamps=timestamps,
    frame_step=1,
    min_confidence=card.confidence_threshold,
)
subject_boxes = box_tracks.exclude_edge_boxes().primary_tracks()
image_points = all_points.for_boxes(subject_boxes)

# Solve poses from unconstrained body keypoints.
# Keep the measured intrinsics fixed.
run = calibrate_extrinsics(
    image_points,
    cameras,
    constraints=None,
    refine_intrinsics=False,
)
volume = run.capture_volume

# Anchor scale to subject height, orient +Z from GeoCalib vertical, and set the floor.
vertical = estimate_vertical(VIDEOS, cameras)
volume = volume.scaled(card.stature_cue(meters=SUBJECT_HEIGHT_M))
volume = volume.oriented(up=vertical.up_per_cam)
volume = volume.grounded()
volume = volume.centered()

print_extrinsic_report(volume)
volume.save(OUTPUT_DIR)
volume.camera_array.to_aniposelib_toml(OUTPUT_DIR.parent / "camera_array_aniposelib.toml")

The first run downloads the RTMPose and detector weights if they are absent from MODELS_DIR. The detector sees every processed frame; keypoint inference sees only the retained subject boxes. Each pass reads the source videos; no wall-time speedup is assumed. The GeoCalib model also downloads to MODELS_DIR the first time estimate_vertical runs.

BoxTracks supports to_csv and from_csv, so you can save detections and change the selected track or edge margin without repeating detection. Keypoints already saved as ImagePoints can also be reloaded. Selecting previously unprocessed boxes requires keypoint inference for those boxes. The returned image points use object_id=0 for the selected person and retain camera-local track_id and keypoint confidence as additional columns. Missing observations remain absent; no boxes or keypoints are interpolated by these stages.

Grounding places the lowest tracked point at Z=0. It does not detect the physical floor. Use lowest_point_height_m when a reliably tracked low point, such as a foot keypoint, has a known height above the floor. Use mode="pooled_1st_percentile" only when a few reconstructed points lie below the true floor. See the grounding options for examples.

Inspect the calibration

# Optional: view the calibrated cameras and tracked person in 3D.
# Requires: uv pip install "caliscope[gui]" (includes tracking).
from caliscope.gui import view_capture_volume

view_capture_volume(volume, wireframe=tracker.wireframe, fps=30)

Run the viewer from a standalone Python script. It opens an interactive window and pauses the script until you close it.

The saved directory contains the camera array and the 2D and 3D points used for the result. You can reopen it later without loading a tracker or model card.

from caliscope.api import CaptureVolume
from caliscope.gui import view_capture_volume

volume = CaptureVolume.load("markerless_capture_volume")
view_capture_volume(volume, fps=30)

The viewer can display the points without a wireframe. Pass the wireframe from a loaded model card when you want the Halpe26 skeleton overlay. Its fps value sets the playback cadence for the available samples. It does not reproduce the recording timestamps.

What to check

Inspect the report, camera layout, and motion before using the calibration for measurement. A low reprojection error and a plausible 3D view do not establish measurement accuracy. Look for views that overlap through the motion, a vertical direction that agrees with the scene, and a scale that agrees with an independent measurement.

Calibration and motion capture

The person detector and pose estimator supply image observations for calibration and reconstruction. Calibration uses those correspondences to estimate camera poses; reconstruction uses known camera poses to triangulate them. Both depend on selecting the same person across views. With several people in view, cross-camera track association makes that selection once the cameras are calibrated.

Caliscope's reconstruction supports calibration inspection and landmark export. For downstream motion-capture processing, export the camera calibration to tools such as Pose2Sim or anipose. See the reconstruction scope and aniposelib export.