Пример #1
0
def test_corresponding_tracks():
    t1 = {1: pysfm.Observation(1.0, 1.0, 1.0, 0, 0, 0, 1)}
    t2 = {1: pysfm.Observation(1.0, 1.0, 1.0, 0, 0, 0, 2)}

    correspondences = reconstruction.corresponding_tracks(t1, t2)
    assert len(correspondences) == 0

    t1 = {1: pysfm.Observation(1.0, 1.0, 1.0, 0, 0, 0, 3)}
    t2 = {2: pysfm.Observation(1.0, 1.0, 1.0, 0, 0, 0, 3)}

    correspondences = reconstruction.corresponding_tracks(t1, t2)
    assert len(correspondences) == 1
    assert correspondences[0] == (1, 2)

    t1 = {1: pysfm.Observation(1.0, 1.0, 1.0, 0, 0, 0, 3),
          2: pysfm.Observation(1.0, 1.0, 1.0, 0, 0, 0, 4)}
    t2 = {1: pysfm.Observation(1.0, 1.0, 1.0, 0, 0, 0, 4),
          2: pysfm.Observation(1.0, 1.0, 1.0, 0, 0, 0, 5)}

    correspondences = reconstruction.corresponding_tracks(t1, t2)
    assert len(correspondences) == 1
    assert correspondences[0] == (2, 1)

    t1 = {1: pysfm.Observation(1.0, 1.0, 1.0, 0, 0, 0, 5),
          2: pysfm.Observation(1.0, 1.0, 1.0, 0, 0, 0, 6)}
    t2 = {3: pysfm.Observation(1.0, 1.0, 1.0, 0, 0, 0, 5),
          4: pysfm.Observation(1.0, 1.0, 1.0, 0, 0, 0, 6)}

    correspondences = reconstruction.corresponding_tracks(t1, t2)
    correspondences.sort(key=lambda c: c[0] + c[1])
    assert len(correspondences) == 2
    assert correspondences[0] == (1, 3)
    assert correspondences[1] == (2, 4)
def test_corresponding_tracks():
    t1 = {1: {"feature_id": 1}}
    t2 = {1: {"feature_id": 2}}

    correspondences = reconstruction.corresponding_tracks(t1, t2)
    assert len(correspondences) == 0

    t1 = {1: {"feature_id": 3}}
    t2 = {2: {"feature_id": 3}}

    correspondences = reconstruction.corresponding_tracks(t1, t2)
    assert len(correspondences) == 1
    assert correspondences[0] == (1, 2)

    t1 = {1: {"feature_id": 3}, 2: {"feature_id": 4}}
    t2 = {1: {"feature_id": 4}, 2: {"feature_id": 5}}

    correspondences = reconstruction.corresponding_tracks(t1, t2)
    assert len(correspondences) == 1
    assert correspondences[0] == (2, 1)

    t1 = {1: {"feature_id": 5}, 2: {"feature_id": 6}}
    t2 = {3: {"feature_id": 5}, 4: {"feature_id": 6}}

    correspondences = reconstruction.corresponding_tracks(t1, t2)
    correspondences.sort(key=lambda c: c[0] + c[1])
    assert len(correspondences) == 2
    assert correspondences[0] == (1, 3)
    assert correspondences[1] == (2, 4)
def test_corresponding_tracks() -> None:
    t1 = {1: pymap.Observation(1.0, 1.0, 1.0, 0, 0, 0, 1, 1, 1)}
    t2 = {1: pymap.Observation(1.0, 1.0, 1.0, 0, 0, 0, 2, 2, 2)}

    # pyre-fixme[6]: For 1st param expected `Dict[str, Observation]` but got
    #  `Dict[int, Observation]`.
    # pyre-fixme[6]: For 2nd param expected `Dict[str, Observation]` but got
    #  `Dict[int, Observation]`.
    correspondences = reconstruction.corresponding_tracks(t1, t2)
    assert len(correspondences) == 0

    t1 = {1: pymap.Observation(1.0, 1.0, 1.0, 0, 0, 0, 3, 3, 3)}
    t2 = {2: pymap.Observation(1.0, 1.0, 1.0, 0, 0, 0, 3, 3, 3)}

    # pyre-fixme[6]: For 1st param expected `Dict[str, Observation]` but got
    #  `Dict[int, Observation]`.
    # pyre-fixme[6]: For 2nd param expected `Dict[str, Observation]` but got
    #  `Dict[int, Observation]`.
    correspondences = reconstruction.corresponding_tracks(t1, t2)
    assert len(correspondences) == 1
    assert correspondences[0] == (1, 2)

    t1 = {
        1: pymap.Observation(1.0, 1.0, 1.0, 0, 0, 0, 3, 3, 3),
        2: pymap.Observation(1.0, 1.0, 1.0, 0, 0, 0, 4, 4, 4),
    }
    t2 = {
        1: pymap.Observation(1.0, 1.0, 1.0, 0, 0, 0, 4, 4, 4),
        2: pymap.Observation(1.0, 1.0, 1.0, 0, 0, 0, 5, 5, 5),
    }

    # pyre-fixme[6]: For 1st param expected `Dict[str, Observation]` but got
    #  `Dict[int, Observation]`.
    # pyre-fixme[6]: For 2nd param expected `Dict[str, Observation]` but got
    #  `Dict[int, Observation]`.
    correspondences = reconstruction.corresponding_tracks(t1, t2)
    assert len(correspondences) == 1
    assert correspondences[0] == (2, 1)

    t1 = {
        1: pymap.Observation(1.0, 1.0, 1.0, 0, 0, 0, 5, 5, 5),
        2: pymap.Observation(1.0, 1.0, 1.0, 0, 0, 0, 6, 6, 6),
    }
    t2 = {
        3: pymap.Observation(1.0, 1.0, 1.0, 0, 0, 0, 5, 5, 5),
        4: pymap.Observation(1.0, 1.0, 1.0, 0, 0, 0, 6, 6, 6),
    }

    # pyre-fixme[6]: For 1st param expected `Dict[str, Observation]` but got
    #  `Dict[int, Observation]`.
    # pyre-fixme[6]: For 2nd param expected `Dict[str, Observation]` but got
    #  `Dict[int, Observation]`.
    correspondences = reconstruction.corresponding_tracks(t1, t2)
    correspondences.sort(key=lambda c: c[0] + c[1])
    assert len(correspondences) == 2
    assert correspondences[0] == (1, 3)
    assert correspondences[1] == (2, 4)