Skip to content

Instantly share code, notes, and snippets.

@andijakl
Created November 23, 2020 16:42
Show Gist options
  • Save andijakl/ef1cb98e28716fa1e009ec8f4df3b200 to your computer and use it in GitHub Desktop.
Save andijakl/ef1cb98e28716fa1e009ec8f4df3b200 to your computer and use it in GitHub Desktop.
Calculate the fundamental matrix for stereo rectification
# ------------------------------------------------------------
# STEREO RECTIFICATION
# Calculate the fundamental matrix for the cameras
# https://docs.opencv.org/master/da/de9/tutorial_py_epipolar_geometry.html
pts1 = np.int32(pts1)
pts2 = np.int32(pts2)
fundamental_matrix, inliers = cv.findFundamentalMat(pts1, pts2, cv.FM_RANSAC)
# We select only inlier points
pts1 = pts1[inliers.ravel() == 1]
pts2 = pts2[inliers.ravel() == 1]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment