[Python] How to get 3D points from 2D point pairs and fundamental matrix?

Discussão em 'Python' iniciado por Stack, Março 2, 2025.

  1. Stack

    Stack Membro Participativo

    I'm trying to reconstruct objects from Internet photographs. In most cases, I have only two images, so I'm looking for methods that can compute 3D points from a pair of images.

    I have the following code, based on this tutorial, which seems to compute a reasonable¹ fundamental matrix:

    def readMatches(...):
    # Returns a set of (manually annotated) point matches
    # sufficient for computing the fundamental matrix.


    def computePose(pts1, pts2):
    pts1 = np.int32(pts1)
    pts2 = np.int32(pts2)
    F, mask = cv.findFundamentalMat(pts1, pts2, cv.FM_LMEDS)

    pts1 = pts1[mask.ravel() == 1]
    pts2 = pts2[mask.ravel() == 1]

    return pts1, pts2, F


    if __name__ == '__main__':
    pts1, pts2 = readMatches(...)
    pts1, pts2, F = computePose(pts1, pts2)


    (¹ At least, drawing the epipolar lines using the code in the tutorial produces a result that looks reasonable.)

    What is the next step to go from this to a 3D point cloud of the input points? (If it helps, I can provide a set of point pairs for one of the inputs that should form a series of parallel lines. That is all I have to go on as far as camera intrinsics, however.)

    Python OpenCV code is preferred. Please refrain from posting answers that require purchasing a book.

    Continue reading...

Compartilhe esta Página