alexflint / pysfm

Python implementation of bundle adjustment
55 stars 22 forks source link

Derivation of the Jacobians for fundamental matrix #4

Open jaychak opened 1 year ago

jaychak commented 1 year ago

Alex, first of all my gratitude to you. Your repo is some of the only places on the internet, where I can find some of this SFM stuff coded up from scratch in python. I am specifically looking at your code for stand-alone computation of the Fundamental matrix. Most other people / textbooks would use the standard 8-point algorithm with the closed-form solution with SVD to calculate this. But you are using an iterative solution with Levenberg-Marquardt optimization, which is great and exactly what I was looking for. I have run your code myself - it is written well and it works - but I am puzzled by some of your derivations. Can you give me some pointers/links to how you derived the Jacobians for the Fundamental matrix equations relative to the Rotation and translation matrices? For example, in https://github.com/alexflint/pysfm/blob/master/standalone/fundamental.py lines 87-169, you have functions like the following...

def JxFx_R(K, R, t, x0, x1): Kinv = inv(K) v = dot(Kinv, x0) return dots(x1, Kinv.T, skew(t), R, skew(-v))

I have tried to work out these Jacobians myself, but am not finding them to be close to yours. For example, this above Jacobian of the fundamental matrix equation x'Fx relative to the Rotation matrix, should not have a rotation matrix / term in it. But yours does.

Any pointers at all for how you derived these, would be helpful. Thanks in advance.

Jay

alexflint commented 1 year ago

Thank you!

Yeah these were actually a real pain to derive, particularly the jacobians for the fundamental matrix. I do not have the derivations on hand any more. What I do remember is that when working in the Lie algebra for SO(3), rotation matrices show up within Jacobians in places that wouldn't make sense under Euclidean geometry.

Check out Ethan Eade's "Lie Groups for Computer Vision" and J Sola's "A micro Lie theory for state estimation in robotics"

This looks promising also: https://github.com/norlab-ulaval/cheatsheet_LieAlgebra

Also check out the book referenced in the answer to this stackexchange question that I asked years ago: https://math.stackexchange.com/questions/301533/jacobian-involving-so3-exponential-map-logr-expm