def test_shot_neighborhood_linear_graph() -> None:
    rec = types.Reconstruction()
    cam = pygeometry.Camera.create_perspective(0.5, 0, 0)
    cam.id = "cam1"
    rec.add_camera(cam)
    _add_shot(rec, "im0", cam)
    for i in range(1, 4):
        p, n = "im" + str(i - 1), "im" + str(i)
        _add_shot(rec, n, cam)
        _add_point(rec, str(i), [p, n])

    interior, boundary = reconstruction.shot_neighborhood(
        rec, "im2", radius=1, min_common_points=1, max_interior_size=10
    )
    assert interior == {"im2"}
    assert boundary == {"im1", "im3"}

    interior, boundary = reconstruction.shot_neighborhood(
        rec, "im2", radius=2, min_common_points=1, max_interior_size=10
    )
    assert interior == {"im1", "im2", "im3"}
    assert boundary == {"im0"}

    interior, boundary = reconstruction.shot_neighborhood(
        rec, "im2", radius=3, min_common_points=1, max_interior_size=10
    )
    assert interior == {"im0", "im1", "im2", "im3"}
    assert boundary == set()

    interior, boundary = reconstruction.shot_neighborhood(
        rec, "im2", radius=3, min_common_points=1, max_interior_size=3
    )
    assert interior == {"im1", "im2", "im3"}
    assert boundary == {"im0"}
def test_shot_neighborhood_sorted_results() -> None:
    rec = types.Reconstruction()
    cam = pygeometry.Camera.create_perspective(0.5, 0, 0)
    cam.id = "cam1"
    rec.add_camera(cam)
    _add_shot(rec, "im0", cam)
    _add_shot(rec, "im1", cam)
    _add_shot(rec, "im2", cam)
    _add_point(rec, "1", ["im0", "im1"])
    _add_point(rec, "2", ["im0", "im1"])
    _add_point(rec, "3", ["im0", "im2"])

    interior, boundary = reconstruction.shot_neighborhood(
        rec, "im0", radius=2, min_common_points=1, max_interior_size=2
    )
    assert interior == {"im0", "im1"}
    assert boundary == {"im2"}

    _add_point(rec, "4", ["im0", "im2"])
    _add_point(rec, "5", ["im0", "im2"])

    interior, boundary = reconstruction.shot_neighborhood(
        rec, "im0", radius=2, min_common_points=1, max_interior_size=2
    )
    assert interior == {"im0", "im2"}
    assert boundary == {"im1"}
Ejemplo n.º 3
0
def test_shot_neighborhood_sorted_results():
    rec = types.Reconstruction()
    cam = pygeometry.Camera.create_perspective(0.5, 0, 0)
    cam.id = "cam1"
    rec.add_camera(cam)
    _add_shot(rec, 'im0', cam)
    _add_shot(rec, 'im1', cam)
    _add_shot(rec, 'im2', cam)
    _add_point(rec, '1', ['im0', 'im1'])
    _add_point(rec, '2', ['im0', 'im1'])
    _add_point(rec, '3', ['im0', 'im2'])

    interior, boundary = reconstruction.shot_neighborhood(rec,
                                                          'im0',
                                                          radius=2,
                                                          min_common_points=1,
                                                          max_interior_size=2)
    assert interior == {'im0', 'im1'}
    assert boundary == {'im2'}

    _add_point(rec, '4', ['im0', 'im2'])
    _add_point(rec, '5', ['im0', 'im2'])

    interior, boundary = reconstruction.shot_neighborhood(rec,
                                                          'im0',
                                                          radius=2,
                                                          min_common_points=1,
                                                          max_interior_size=2)
    assert interior == {'im0', 'im2'}
    assert boundary == {'im1'}
Ejemplo n.º 4
0
def test_shot_neighborhood_sorted_results():
    graph = nx.Graph()
    rec = types.Reconstruction()
    _add_shot(graph, rec, 'im0')
    _add_shot(graph, rec, 'im1')
    _add_shot(graph, rec, 'im2')
    _add_point(graph, rec, '1', ['im0', 'im1'])
    _add_point(graph, rec, '2', ['im0', 'im1'])
    _add_point(graph, rec, '3', ['im0', 'im2'])

    interior, boundary = reconstruction.shot_neighborhood(graph,
                                                          rec,
                                                          'im0',
                                                          radius=2,
                                                          min_common_points=1,
                                                          max_interior_size=2)
    assert interior == set(['im0', 'im1'])
    assert boundary == set(['im2'])

    _add_point(graph, rec, '4', ['im0', 'im2'])
    _add_point(graph, rec, '5', ['im0', 'im2'])

    interior, boundary = reconstruction.shot_neighborhood(graph,
                                                          rec,
                                                          'im0',
                                                          radius=2,
                                                          min_common_points=1,
                                                          max_interior_size=2)
    assert interior == set(['im0', 'im2'])
    assert boundary == set(['im1'])
Ejemplo n.º 5
0
def test_shot_neighborhood_linear_graph():
    graph = nx.Graph()
    rec = types.Reconstruction()
    _add_shot(graph, rec, 'im0')
    for i in range(1, 4):
        p, n = 'im' + str(i - 1), 'im' + str(i)
        _add_shot(graph, rec, n)
        _add_point(graph, rec, str(i), [p, n])

    interior, boundary = reconstruction.shot_neighborhood(graph,
                                                          rec,
                                                          'im2',
                                                          radius=1,
                                                          min_common_points=1,
                                                          max_interior_size=10)
    assert interior == set(['im2'])
    assert boundary == set(['im1', 'im3'])

    interior, boundary = reconstruction.shot_neighborhood(graph,
                                                          rec,
                                                          'im2',
                                                          radius=2,
                                                          min_common_points=1,
                                                          max_interior_size=10)
    assert interior == set(['im1', 'im2', 'im3'])
    assert boundary == set(['im0'])

    interior, boundary = reconstruction.shot_neighborhood(graph,
                                                          rec,
                                                          'im2',
                                                          radius=3,
                                                          min_common_points=1,
                                                          max_interior_size=10)
    assert interior == set(['im0', 'im1', 'im2', 'im3'])
    assert boundary == set()

    interior, boundary = reconstruction.shot_neighborhood(graph,
                                                          rec,
                                                          'im2',
                                                          radius=3,
                                                          min_common_points=1,
                                                          max_interior_size=3)
    assert interior == set(['im1', 'im2', 'im3'])
    assert boundary == set(['im0'])
def test_shot_neighborhood_complete_graph() -> None:
    rec = types.Reconstruction()
    cam = pygeometry.Camera.create_perspective(0.5, 0, 0)
    cam.id = "cam1"
    rec.add_camera(cam)
    for i in range(4):
        _add_shot(rec, "im" + str(i), cam)
    _add_point(rec, "1", rec.shots.keys())

    interior, boundary = reconstruction.shot_neighborhood(
        rec, "im2", radius=2, min_common_points=1, max_interior_size=10
    )
    assert interior == {"im0", "im1", "im2", "im3"}
    assert boundary == set()
Ejemplo n.º 7
0
def test_shot_neighborhood_complete_graph():
    graph = nx.Graph()
    rec = types.Reconstruction()
    for i in range(4):
        _add_shot(graph, rec, 'im' + str(i))
    _add_point(graph, rec, '1', rec.shots.keys())

    interior, boundary = reconstruction.shot_neighborhood(graph,
                                                          rec,
                                                          'im2',
                                                          radius=2,
                                                          min_common_points=1,
                                                          max_interior_size=10)
    assert interior == set(['im0', 'im1', 'im2', 'im3'])
    assert boundary == set()