From point correspondences:
x1 and x2 are 3xN array of normalized points from images 1 and 2.
E = cv2.findFundamentalMat(x1[:2].T, x2[:2].T)[0]
Note: This cv2 method requires points to be in Nx2 format.
The ending [0] returns the matrix. The 2nd returned value [1] is a mask array of inliers (=1) and outliers (=0)
From transformation/projection matrix:
P is a 3×4 (or 4×4) camera projection matrix for image 2.
(World origin at image 1 camera)
R,t = cv2.decomposeProjectionMatrix(P[:3])[1:3] skewt = roll(roll(diag(t.flat[:3]/t[3]), 1, 1), -1, 0) skewt -= skewt.T E = dot(R, skewt)
Note: This method requires a 3×4 array and returns seven items, [1] and [2] are the rotation matrix and translation vector. Also, the t-vec has length 4 and must be normalized by the last value (t[:3]/t[3])
roll, diag, .flat, dot are all NumPy functions.