Skip to content

Conversation

@mattdawkins
Copy link
Member

@mattdawkins mattdawkins commented Jan 17, 2026

Remember Last Calibration File

Summary

This PR adds functionality to remember and automatically use the last calibration file that was entered or generated in the DIVE Desktop application. This improves the user experience when working with stereo camera datasets by reducing repetitive file selection.

Features

1. Calibration File Persistence

  • The application now saves the last used calibration file to last_calibration.json in the data directory
  • This calibration file persists across application sessions

2. Auto-Loading in Import Dialog

  • When opening the multi-camera import dialog for stereo imports, the last calibration file is automatically loaded and pre-filled
  • Users can still manually select a different calibration file if needed

3. Automatic Saving

The calibration file is automatically saved in two scenarios:

  • Manual Selection: When a user selects a calibration file through the file picker in the import dialog
  • Pipeline Generation: When a calibration pipeline (e.g., calibrate_cameras) completes successfully, the generated calibration file is automatically saved as the new default

4. Auto-Application to Uncalibrated Datasets

  • When a calibration file is saved (either manually selected or generated), it is automatically applied to all existing stereo datasets that don't already have a calibration file set
  • This ensures consistency across stereo datasets and reduces manual configuration

Technical Changes

Frontend (client/)

  • dive-common/components/ImportMultiCamDialog.vue:

    • Added onMounted hook to load the last calibration file when the dialog opens for stereo imports
    • Added logic to save the calibration file when a user selects one via the file picker
  • dive-common/apispec.ts:

    • Added optional API methods: getLastCalibration() and saveCalibration()
    • These methods are desktop-only (optional in the API interface)
  • platform/desktop/frontend/api.ts:

    • Implemented getLastCalibration() and saveCalibration() functions using IPC communication

Backend (client/platform/desktop/backend/)

  • ipcService.ts:

    • Added IPC handlers: get-last-calibration and save-calibration
    • The save handler also triggers auto-application to uncalibrated stereo datasets
  • native/common.ts:

    • Added getLastCalibrationPath(): Retrieves the path to the saved calibration file
    • Added saveLastCalibration(): Saves a calibration file to the data directory
    • Added applyCalibrationToUncalibratedStereoDatasets(): Applies a calibration file to all stereo datasets without existing calibration
  • native/viame.ts:

    • Added detection for calibration pipeline completion
    • Automatically saves and applies generated calibration files when calibration pipelines finish successfully
  • constants.ts:

    • Added LastCalibrationFileName constant ('last_calibration.json')

Benefits

  1. Improved Workflow: Users no longer need to repeatedly select the same calibration file when importing multiple stereo datasets
  2. Consistency: Automatically applies calibration to uncalibrated stereo datasets, ensuring all datasets use the same calibration when appropriate
  3. Pipeline Integration: Seamlessly integrates with calibration pipelines, automatically saving and applying generated calibration files
  4. Backward Compatible: Existing datasets with calibration files are not affected; only uncalibrated stereo datasets receive the new calibration

Testing Considerations

  • Verify that the last calibration file is loaded when opening the stereo import dialog
  • Confirm that manually selected calibration files are saved and persist across sessions
  • Test that calibration files generated from pipelines are automatically saved
  • Verify that uncalibrated stereo datasets receive the calibration when it's saved
  • Ensure that datasets with existing calibration files are not modified
  • Test error handling for missing or invalid calibration files

@BryonLewis BryonLewis self-requested a review January 17, 2026 15:28
Copy link
Collaborator

@BryonLewis BryonLewis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks relatively good.
I didn't run it because I need to find some new calibration files and use them.
As long as you've tested it locally and it does what is expected, I'm fine with merging.

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.

2 participants