Skip to content

Stereo camera-file import/export, display, and length clearing#1710

Open
mattdawkins wants to merge 26 commits into
mainfrom
dev/stereo-camera-file-io
Open

Stereo camera-file import/export, display, and length clearing#1710
mattdawkins wants to merge 26 commits into
mainfrom
dev/stereo-camera-file-io

Conversation

@mattdawkins

@mattdawkins mattdawkins commented Jun 22, 2026

Copy link
Copy Markdown
Member

Stereo Camera File I/O — Branch Feature Summary

Stereo Camera / Calibration File I/O

End-to-end support for stereoscopic calibration (“camera”) files on stereo and multicam datasets, on both web and desktop.

  • Import VIAME-supported formats (.npz, .json, .cam, .yml, .zip) from the viewer Import menu or during multicam dataset creation
  • Export the current calibration file from desktop (dedicated export action and bundled multicam export)
  • Normalize non-JSON calibrations to KWIVER JSON camera-rig format via VIAME convert_cam_format.py, while keeping the original file
  • Separate storage of source calibration vs. derived JSON (calibrationFile / jsonCalibrationFile items on web; parallel metadata on desktop)
  • Handle edge cases: mislabeled files (e.g. .npz named .json), missing parameters, and files that cannot be fully parsed (filename still reported)

Calibration Viewing & Management

New in-viewer calibration UI shared across web and desktop.

  • Calibration menu (checkerboard icon) in the viewer toolbar
  • Calibration dialog showing parsed stereo parameters: per-camera intrinsics/distortion, rotation/translation, image size, checkerboard grid, RMS error, etc.
  • Download and delete calibration from the dialog
  • Disabled icon state when no calibration is loaded, with tooltip guidance to use Import
  • Filename display in tooltip and dialog (original source name vs. JSON path)

Import UX Enhancements

Calibration import is integrated into existing import flows rather than a separate workflow.

  • “Import Camera File” section in the Import Annotations menu (stereo datasets only)
  • “Use last calibration” shortcut (desktop last-path persistence; web session registry)
  • Auto-discovery of calibration in the parent folder during multicam import when none is selected
  • Optional “Reset length measurements” checkbox when importing a new camera file (default on)
  • Active camera indicator in Import menu for multicam datasets (annotations import to the active camera)

Web / Girder Backend

Server-side calibration storage, retrieval, and conversion for web datasets.

  • GET dive_dataset/calibration — returns calibration metadata and parsed JSON parameters when available
  • POST dive_dataset/:id/calibration — associates an uploaded Girder file as the dataset calibration
  • Background conversion task (convert_calibration) on the pipelines worker queue for non-JSON formats
  • Multicam dataset creation accepts an optional calibrationFileId
  • Pipeline integration — stereo measurement pipelines download and pass calibration into KWIVER settings

Desktop Backend

Local file-based calibration handling mirroring web behavior.

  • importCalibrationFile / exportCalibrationFile IPC APIs
  • VIAME-based conversion in the desktop native layer (calibrationConvert.ts)
  • Parent-folder calibration discovery when none is explicitly set
  • Last-calibration persistence for quick reuse across datasets
  • Metadata tracking of source path, stored path, and original filename

Desktop Export: “Everything” Bundle

Expanded export options for multicam datasets.

  • Export calibration file as its own action from the Export menu
  • “Export Everything” — zip containing multiCam.json, per-camera annotation exports, and the calibration file

Dataset Source Info (Desktop)

New dialog for inspecting and opening dataset file locations.

  • Shows project directory, media source, per-camera source folders, and calibration path
  • Open in file manager actions for linked paths
  • Available from the viewer and recent datasets list

Length Measurement Invalidation

Safety behavior when calibration changes invalidate existing stereo measurements.

  • clearLengthAttributes utility clears length (and optionally length_method) across all cameras
  • Triggered on calibration import when “Reset length measurements” is checked
  • New clearLengthOnCameraFileLoad stereo setting (default: enabled)

Toolbar & UI Polish

Supporting UI work to fit new controls and improve toolbar layout.

  • Collapsible toolbar groups via OutlinedLabeledGroup and ToolbarExpandToggle
  • Refactored Annotation Visibility and Editor menus to use grouped, expandable buttons
  • Smaller camera selection UI in multicam toolbar
  • Compressed button-group text areas for denser toolbars

Types & API Surface

Shared client/server contracts for calibration data.

  • New CameraCalibration, DatasetStereoCalibration, and DatasetCalibrationResult types
  • Extended apispec with calibration get/import/export/download/delete hooks for both platforms

@mattdawkins mattdawkins requested a review from BryonLewis June 22, 2026 17:22
mattdawkins and others added 8 commits June 26, 2026 10:53
Add desktop import/export of stereo camera/calibration files via the annotation Import/Export buttons, display the loaded camera file in stereo mode, and clear 'length' attributes from tracks/detections when a new camera file loads (toggle in user settings). On import/upload, any VIAME-supported calibration is converted to the JSON camera format via convert_cam_format.py and stored with the dataset, keeping the original.
(cherry picked from commit 48b84de)
Implement a desktop getDatasetCalibration that parses the stored camera-rig JSON, plus cross-platform download/delete, so the checkerboard calibration menu and dialog now function in Electron instead of being web-only. Display the loaded calibration file name in the dialog and tooltip on both desktop and web, and return the file name from the server calibration endpoint.

(cherry picked from commit ffaf012)
setDatasetCalibration and exportDatasetCalibration now resolve the parent
dataset id (via datasetId.split('/')[0]) instead of using a per-camera child
id like <parent>/left, which has no multiCam metadata and caused import to
fail.

(cherry picked from commit 5a2279a)
…ngth option, UI tweaks

prepareDatasetCalibration now validates JSON content and converts a binary file
mislabeled .json (e.g. an .npz copied to last_calibration.json); the last-used
backup keeps the source extension. The user's original calibration filename is
recorded (calibrationOriginalName) and shown in the menu/dialog. The Import menu
gains a 'Reset all length measurements' checkbox that clears length and
length_method across all tracks. The calibration button moved to the top toolbar
(icon-only, always shown on stereo), reads on dialog open, and the info dialog
text was updated.

(cherry picked from commit d092737)
Move the reset-length checkbox below the camera-file Import button (matching the
annotation-import layout), relabel buttons/sections, stop showing the loaded
calibration filename, and drop the JSON-conversion mention.

(cherry picked from commit 39aff5c)
@mattdawkins mattdawkins force-pushed the dev/stereo-camera-file-io branch from ea6e72c to 7b7cd20 Compare June 26, 2026 15:01
mattdawkins and others added 18 commits June 26, 2026 11:06
get_calibration no longer 400s/500s for a non-JSON (e.g. .npz) or malformed
calibration file; it returns the item id and filename so the viewer shows the
calibration as loaded, mirroring desktop's graceful handling.
Add a POST dive_dataset/:id/calibration endpoint and crud_dataset.set_calibration
that marks an uploaded file as the dataset's stereo calibration (replacing any
prior). Implement web importCalibrationFile (upload to the dataset folder, then
mark) and wire it into provideApi, which enables the shared Import Camera File
section and the reset-length checkbox on web.
Add a convert_calibration celery task that runs VIAME's convert_cam_format.py on
the worker (download item -> convert npz/yml/etc -> upload .json into the same
item), so the viewer can display calibration parameters. Enqueued from
set_calibration and multicam creation when the uploaded file isn't already JSON;
best-effort since stereo pipelines read the original file directly.
The top-level 'platform/web-girder/plugins/girder' import touches window at module
load, which broke the node-environment multicamFileRegistry.spec (ReferenceError:
window is not defined). Import girderRest lazily inside importCalibrationFile so the
module graph stays test-safe.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants