scipy-cookbook icon indicating copy to clipboard operation
scipy-cookbook copied to clipboard

Update bundle adjustment

Open nmayorov opened this issue 3 years ago • 2 comments
trafficstars

I have done some improvements on this notebook:

  1. Clarify definition of camera parameters
  2. Add a comment about relation between images and cameras for this particular setup
  3. Slightly reworked the core part
  4. Replace self-written function for rotation transform with Rotation class

Link to the updated notebook file

https://github.com/scipy/scipy-cookbook/blob/9e136daac9df507db7bf114bf319e6ade9723c21/ipython/bundle_adjustment.ipynb

Fixes #44

nmayorov avatar May 04 '22 07:05 nmayorov

@rgommers

If you have time / interest check this too, I believe it is a clear improvement and safe to merge.

But let's wait for the people from the issues to comment.

nmayorov avatar May 04 '22 07:05 nmayorov

That looks great! I was translating this notebook from scipy to PyTorch and the original Rodrigues vector to unit quaternion implementation introduced some numeric instabiliity that took me a while to hunt down. Your change will solve this issue.

The code that introduced numeric instability:

theta = np.linalg.norm(camera_params[:, :3], axis=1)[:, np.newaxis]
with np.errstate(invalid='ignore'):
    v = camera_params[:, :3] / theta
    v = np.nan_to_num(v)

hxu296 avatar Jul 07 '23 07:07 hxu296