Skip to content
Proyectos

jerredchen/image-as-an-imu

Ver en GitHub

Acerca de

Image as an IMU: Estimating Camera Motion from a Single Motion-Blurred Image

Diseño y multimedia

Cómo se miden estas cifras

Crecimiento de estrellas medido

in 24h
0
in 7 days
0
in 15 days
0
in 1 month
Recopilando historial

Cambios netos en períodos que se solapan, no totales diarios. Los datos no disponibles se dejan en blanco. Las estrellas indican interés, no calidad.

README.md

Original

Image as an IMU: Estimating Camera Motion from a Single Motion-Blurred Image

teaser

Official implementation of Image as an IMU: Estimating Camera Motion from a Single Motion-Blurred Image, ICCV 2025 (Oral).

[arXiv] [Webpage]

PIXL, University of Oxford

Jerred Chen, Ronald Clark

@inproceedings{chen2025imageimu,
  title={Image as an IMU: Estimating Camera Motion from a Single Motion-Blurred Image},
  author={Chen, Jerred and Clark, Ronald},
  booktitle={International Conference of Computer Vision (ICCV)},
  year={2025}
}

News

  • [Nov 26 2025] We've released the real-world finetuning dataset, which can be accessed here.

Getting Started

First, create a new conda environment.

conda create -n image-as-imu python=3.10
conda activate image-as-imu

Then, clone the repo and install the dependencies.

git clone https://github.com/jerredchen/image-as-an-imu.git
cd image-as-an-imu
pip install torch==2.6.0 torchvision==0.21.0 --index-url https://download.pytorch.org/whl/cu118
pip install -r requirements.txt

Finally, install the iaai module.

pip install -e .

Download the model weights:

Backbone Checkpoint
SegNeXt Download

To run a minimal example, we provide run.py which takes in a single motion-blurred image and estimates the velocity, given the known focal length and exposure time.

import torch
from PIL import Image
from iaai.model import Blur2PoseSegNeXtBackbone
from iaai.funcs import compute_single_image_velocity

model = Blur2PoseSegNeXtBackbone(device="cuda")
state_dict = torch.load("/path/to/model_ckpt.pth")
model.load_state_dict(state_dict, strict=True)
model.eval().cuda()

demo_img = Image.open("./assets/demo.jpg")
data = {"image": demo_img, "fx": 1433.1024, "fy": 1433.1024}
out = model.infer(data) # out is a dict with keys "flow_field", "depth", "pose", "residual"
# Optionally apply a transformation to the rotation matrix
# This transforms the rotation to match the iPhone gyroscope's coordinate system
opencv2gyro_tf = torch.tensor([[ 0, -1,  0],
                               [-1,  0,  0],
                               [ 0,  0, -1]]).float()
rot_vel, trans_vel = compute_single_image_velocity(
    out["pose"].squeeze(),
    exposure_time_s=0.01,
    M=opencv2gyro_tf,
    device="cuda")

# Note that the velocity has sign ambiguity if there is only one image
print(f"Rotational velocity: {rot_vel.cpu().numpy()}")
print(f"Translational velocity: {trans_vel.cpu().numpy()}")

StrayScanner Example

We show how to use our model on a custom StrayScanner recorded sequence, which you can download on iPhone 12 Pro or later Pro models and iPad 2020 Pro or later Pro models. After recording and downloading the sequence, you can process it using process_strayscanner_seq.py and specifying your arguments in process_strayscanner_cfg.yaml. Then, run run_custom_strayscanner_seq.py given your sequence path in run_strayscanner_cfg.yaml.

Note that the StrayScanner app does not currently support accessing the exposure time of the camera. However, in normal lighting conditions you may assume that the exposure time is typically around 0.01 seconds.

Evaluation

We include scripts for evaluating all of our baselines. To evaluate the baselines, follow the installation instructions for hloc, MASt3R, DROID-SLAM, as well as evo. Then, run the respective evaluation script given the specified sequence path in the config. In each config, you may optionally save the velocity outputs of a baseline to be saved to the sequence directory, which can be reused instead of rerunning the method. Download the test sequences used in our paper evaluation here. We slightly modified the StrayScanner app to access the exposure time through the ARKit API.

Synthetic Data Generation

We provide the script for generating the synthetically rendered motion-blurred images. To run this, download ScanNet++, which requires submitting an application. You will also need to follow the installation instructions for RIFE and PromptDA. Then, run synth_data_gen.py with the config synth_data_gen_cfg.yaml. This will generate a CSV file with the paths to load the motion-blurred images, flows, depths, as well as the relative camera pose across the image.

Training

If you wish to train the model from scratch, please also see the synthetic data generation instructions above. You will need to also download the ImageNet-pretrained SegNeXt weights mscan_b.pth from here.

To train the model, run train.py with the desired arguments/hyperparameters in train/configs/train_cfg.yaml. As mentioned in our paper, we train the model in three stages:

  • We first train the model without pose supervision and only train the flow and depth decoders by setting MODEL.POSE_HEAD.SUPERVISION=false.
  • After the flow and depth predictions are reasonable, we further train the pose head with MODEL.POSE_HEAD.SUPERVISION=true.
  • Finally, we finetune with real-world images with MODEL.POSE_HEAD.SUPERVISION=true, TRAINING.POSE_ONLY=true and TRAINING.USE_PSEUDO_GT=true, which prevent the flow and depth predictions from deviating too far from the original outputs. Run generate_pseudo_gt.py to generate the pseudo ground-truth labels.

We provide the hyperparameters that we use for all three stages in separate files. However, we only use the file train/configs/train_cfg.yaml when actually training the model, so the desired hyperparameters can be changed in train_cfg.yaml or in the command line.

TODOs

  • Release the evaluation code
  • Release the training code
  • Release the synthetic data generation code
  • Release the real-world finetuning dataset

Explorar proyectos relacionados

Cargando…