oliver-batchelor / multical

Multi-camera calibration using one or more calibration patterns
Other
358 stars 67 forks source link

Differences between json and camera param table #61

Open ericleonardis opened 9 months ago

ericleonardis commented 9 months ago

The relative camera pose that is described in the JSON (R and T) is not identical to the extrinsic matrix that is displayed in the camera param viewer in the GUI. What is the difference between the camera pose JSON and the extrinsic matrix? Even when I set them in the GUI to have the same reference camera, the parameters are different.

I was able to replicate the parameters JSON by taking the camera pose from the pkl file and then multiplied by the inverse of the reference camera. However, I have been unable to figure out how the extrinsic matrix is being calculated.

felipe-parodi commented 7 months ago

@ericleonardis Did you ever figure this out?

ericleonardis commented 7 months ago

@felipe-parodi unfortunately not... I hope @oliver-batchelor replies some day :(

CodeIsJustLikeMagic commented 6 months ago

Here is how to get the extrinsics displayed in the camera param table:

from multical import tables
from multical.workspace import Workspace
from structs.struct import split_dict # py_structs < 1.0
import numpy as np

ws = Workspace.load("mypath/calibration.pkl")

_, calibs = split_dict(ws.calibrations)
calibration = calibs[1] # <-use the calibrated positions (1) or the initialization positions (0)

poses = calibration.camera_poses.pose_table
poses = tables.inverse(poses)

# adjust for master camera
masterindex = 0
inv = np.linalg.inv(poses.poses[masterindex])
final = poses._extend(poses = poses.poses @ np.expand_dims(inv,0))

print(final.poses)

I'm also struggeling to understand why there are differences between the json and the display. The extrinsics that are used to position the meshes for the 3d view (happens in moving_cameras.py) are difference once again. I'm trying to import the extrinsics into unity to compare them with my simulated ground truth cameras but so far no luck.