facebookresearch / facebookresearch/co-tracker

Difficulty reconstructing camera params from CoTracker Kubric dataset

Open
#158 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Jupyter Notebook
Stars
5.1k
Forks
389
PR merge metrics
No merged PRs in 30d

Description

Hi @nikitakaraevv,

I have been trying to reconstruct the extrinsics and intrinsics matrices from the camera dictionary in the CoTracker Kubric annotation npy file, but I am having trouble. In my code the camera coordinates seem correct but my world coordinates get flattened. I was just wondering if there is something I'm doing wrong.

Thanks

```
import numpy as np
from scipy.spatial.transform import Rotation as R
from PIL import Image
import matplotlib.pyplot as plt

annots = np.load("0002.npy", allow_pickle=True).item()

fx = fy = annots["camera"]["focal_length"]
intrinsics = np.array([
[fx, 0.0, 256.0],
[0.0, fy, 256.0],
[0.0, 0.0, 1.0]
])

for frame_idx in range(annots['camera']["quaternions"].shape[0]):
translation = annots['camera']['positions'][frame_idx]
quaternion = annots['camera']["quaternions"][frame_idx]

extrinsics = np.eye(4, dtype=np.float32)
rot = R.from_quat(quaternion).as_matrix()
extrinsics[:3,:3] = rot.T
extrinsics[:3,3] = -rot.T @ translation

depthmap = np.load(f"depths/{str(frame_idx).zfill(3)}.npy")

colours = []
camera_coords = []
world_coords = []
for y in range(0, 512, 5):
for x in range(0, 512, 5):
z = depthmap[y, x]

x_cam = (x - 256.0) * z / fx
y_cam = (y - 256.0) * z / fy

camera_coord = np.array([[x_cam, y_cam, z, 1.0]])
world_coord = np.matmul(np.linalg.inv(extrinsics), np.transpose(camera_coord, (1, 0)))

camera_coords.append(camera_coord[:, :3])
world_coords.append(world_coord.reshape(4)[:3][None])

camera_coords = np.concatenate(camera_coords, axis=0)
world_coords = np.concatenate(world_coords, axis=0)
```
![Image](https://github.com/user-attachments/assets/fd63dcf9-8e89-448f-b8a8-cc35d8a5f741)

Contributor guide

Open the contributing guide

Research direction

The issue provides a reconstruction script using the Kubric camera dictionary and per-frame depth .npy files, but names no repository file or test. Start by inspecting the annotation and depth inputs alongside the camera-coordinate convention used by CoTracker. Done means the reported world-coordinate flattening is explained and the reconstruction produces valid world coordinates.

Written by the indexing model from the issue text.

Assessment

Tech stack
numpy, python
Domain
computer-vision
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.