Beispiel #1
0
def test_pair_with_shot_point(bundle_adjuster):
    """Simple two camera test with a point constraint for anchoring"""
    sa = bundle_adjuster
    sa.add_shot("1", "cam1", [0, 0, 0], [1e-3, 1e-3, 1e-3], False)
    sa.add_shot("2", "cam1", [0, 0, 0], [1e-3, 1e-3, 1e-3], False)
    sa.add_point("p1", [0, 0, 0], False)
    sa.add_reconstruction("12", False)
    sa.add_reconstruction_shot("12", 4, "1")
    sa.add_reconstruction_shot("12", 4, "2")
    sa.add_rotation_prior("1", 0, 0, 0, 1)
    sa.set_scale_sharing("12", True)
    sa.add_relative_motion(
        pybundle.RelativeMotion("12", "1", "12", "2", [0, 0, 0], [-1, 0, 0],
                                1))
    sa.add_point_position_shot("p1", "1", "12", [1, 0, 0], 1, pybundle.XYZ)
    sa.add_point_position_shot("p1", "2", "12", [-1, 0, 0], 1, pybundle.XYZ)
    sa.add_point_position_world("p1", [1, 0, 0], 1, pybundle.XYZ)

    sa.run()
    s1 = sa.get_shot("1")
    s2 = sa.get_shot("2")
    r12 = sa.get_reconstruction("12")
    p1 = sa.get_point("p1")

    assert np.allclose(s1.t, [0.5, 0, 0], atol=1e-2)
    assert np.allclose(s2.t, [-1.5, 0, 0], atol=1e-2)
    assert np.allclose(p1.p, [1, 0, 0], atol=1e-6)
    assert np.allclose(r12.get_scale("1"), 0.5)
    assert np.allclose(r12.get_scale("2"), 0.5)
Beispiel #2
0
def test_four_cams_one_fixed(bundle_adjuster):
    """Four cameras, one reconstruction"""
    sa = bundle_adjuster
    sa.add_shot("1", "cam1", [0, 0, 0], [0, 0, 0], True)
    sa.add_shot("2", "cam1", [0, 0, 0], [0, 0, 0], False)
    sa.add_shot("3", "cam1", [0, 0, 0], [0, 0, 0], False)
    sa.add_shot("4", "cam1", [0, 0, 0], [0, 0, 0], False)
    sa.add_reconstruction("1234", False)
    sa.add_reconstruction_shot("1234", 1, "1")
    sa.add_reconstruction_shot("1234", 1, "2")
    sa.add_reconstruction_shot("1234", 1, "3")
    sa.add_reconstruction_shot("1234", 1, "4")
    sa.set_scale_sharing("1234", True)
    sa.add_relative_motion(
        pybundle.RelativeMotion("1234", "1", "1234", "2", [0, 0, 0],
                                [-1, 0, 0], 1))
    sa.add_relative_motion(
        pybundle.RelativeMotion("1234", "1", "1234", "3", [0, 0, 0],
                                [0, -1, 0], 1))
    sa.add_relative_motion(
        pybundle.RelativeMotion("1234", "1", "1234", "4", [0, 0, 0],
                                [0, 0, -1], 1))
    sa.add_absolute_position("1", [100, 0, 0], 1, "1")
    sa.add_absolute_position("2", [2, 0, 0], 1, "2")
    sa.add_absolute_position("3", [0, 2, 0], 1, "3")

    sa.run()
    s1 = sa.get_shot("1")
    s2 = sa.get_shot("2")
    s3 = sa.get_shot("3")
    s4 = sa.get_shot("4")

    assert np.allclose(s1.t, [0, 0, 0], atol=1e-6)
    assert np.allclose(s2.t, [-2, 0, 0], atol=1e-6)
    assert np.allclose(s3.t, [0, -2, 0], atol=1e-6)
    assert np.allclose(s4.t, [0, 0, -2], atol=1e-6)
Beispiel #3
0
def test_pair(bundle_adjuster) -> None:
    """Simple two camera test"""
    sa = bundle_adjuster
    sa.add_rig_instance(
        "1",
        # pyre-fixme[6]: For 1st param expected `ndarray` but got `List[int]`.
        # pyre-fixme[6]: For 2nd param expected `ndarray` but got `List[int]`.
        pygeometry.Pose([0, 0, 0], [0, 0, 0]),
        {"1": "cam1"},
        {"1": "rig_cam1"},
        False,
    )
    sa.add_rig_instance(
        "2",
        # pyre-fixme[6]: For 1st param expected `ndarray` but got `List[int]`.
        # pyre-fixme[6]: For 2nd param expected `ndarray` but got `List[int]`.
        pygeometry.Pose([0, 0, 0], [0, 0, 0]),
        {"2": "cam1"},
        {"2": "rig_cam1"},
        False,
    )
    sa.add_reconstruction("12", False)
    sa.add_reconstruction_instance("12", 4, "1")
    sa.add_reconstruction_instance("12", 4, "2")
    sa.set_scale_sharing("12", True)
    sa.add_relative_motion(
        # pyre-fixme[6]: For 5th param expected `ndarray` but got `List[int]`.
        # pyre-fixme[6]: For 6th param expected `ndarray` but got `List[int]`.
        pybundle.RelativeMotion("12", "1", "12", "2", [0, 0, 0], [-1, 0, 0],
                                1))
    sa.add_rig_instance_position_prior("1", [0, 0, 0], [1, 1, 1], "")
    sa.add_rig_instance_position_prior("2", [2, 0, 0], [1, 1, 1], "")

    sa.run()
    s1 = sa.get_rig_instance_pose("1")
    s2 = sa.get_rig_instance_pose("2")
    r12 = sa.get_reconstruction("12")

    assert np.allclose(s1.translation, [0, 0, 0], atol=1e-6)
    assert np.allclose(s2.translation, [-2, 0, 0], atol=1e-6)
    assert np.allclose(r12.get_scale("1"), 0.5)
    assert np.allclose(r12.get_scale("2"), 0.5)
Beispiel #4
0
def test_pair(bundle_adjuster):
    """Simple two camera test"""
    sa = bundle_adjuster
    sa.add_shot("1", "cam1", [0, 0, 0], [0, 0, 0], False)
    sa.add_shot("2", "cam1", [0, 0, 0], [0, 0, 0], False)
    sa.add_reconstruction("12", False)
    sa.add_reconstruction_shot("12", 4, "1")
    sa.add_reconstruction_shot("12", 4, "2")
    sa.set_scale_sharing("12", True)
    sa.add_relative_motion(
        pybundle.RelativeMotion("12", "1", "12", "2", [0, 0, 0], [-1, 0, 0],
                                1))
    sa.add_absolute_position("1", [0, 0, 0], 1, "1")
    sa.add_absolute_position("2", [2, 0, 0], 1, "2")

    sa.run()
    s1 = sa.get_shot("1")
    s2 = sa.get_shot("2")
    r12 = sa.get_reconstruction("12")

    assert np.allclose(s1.t, [0, 0, 0], atol=1e-6)
    assert np.allclose(s2.t, [-2, 0, 0], atol=1e-6)
    assert np.allclose(r12.get_scale("1"), 0.5)
    assert np.allclose(r12.get_scale("2"), 0.5)
Beispiel #5
0
def test_four_cams_one_fixed(bundle_adjuster) -> None:
    """Four rigs, one reconstruction"""
    sa = bundle_adjuster
    sa.add_rig_instance(
        "1",
        # pyre-fixme[6]: For 1st param expected `ndarray` but got `List[int]`.
        # pyre-fixme[6]: For 2nd param expected `ndarray` but got `List[int]`.
        pygeometry.Pose([0, 0, 0], [0, 0, 0]),
        {"1": "cam1"},
        {"1": "rig_cam1"},
        True,
    )
    sa.add_rig_instance(
        "2",
        # pyre-fixme[6]: For 1st param expected `ndarray` but got `List[int]`.
        # pyre-fixme[6]: For 2nd param expected `ndarray` but got `List[int]`.
        pygeometry.Pose([0, 0, 0], [0, 0, 0]),
        {"2": "cam1"},
        {"2": "rig_cam1"},
        False,
    )
    sa.add_rig_instance(
        "3",
        # pyre-fixme[6]: For 1st param expected `ndarray` but got `List[int]`.
        # pyre-fixme[6]: For 2nd param expected `ndarray` but got `List[int]`.
        pygeometry.Pose([0, 0, 0], [0, 0, 0]),
        {"3": "cam1"},
        {"3": "rig_cam1"},
        False,
    )
    sa.add_rig_instance(
        "4",
        # pyre-fixme[6]: For 1st param expected `ndarray` but got `List[float]`.
        # pyre-fixme[6]: For 2nd param expected `ndarray` but got `List[int]`.
        pygeometry.Pose([0.0, 0, 0], [0, 0, 0]),
        {"4": "cam1"},
        {"4": "rig_cam1"},
        False,
    )
    sa.add_reconstruction("1234", False)
    sa.add_reconstruction_instance("1234", 1, "1")
    sa.add_reconstruction_instance("1234", 1, "2")
    sa.add_reconstruction_instance("1234", 1, "3")
    sa.add_reconstruction_instance("1234", 1, "4")
    sa.set_scale_sharing("1234", True)
    sa.add_relative_motion(
        # pyre-fixme[6]: For 5th param expected `ndarray` but got `List[int]`.
        # pyre-fixme[6]: For 6th param expected `ndarray` but got `List[int]`.
        pybundle.RelativeMotion("1234", "1", "1234", "2", [0, 0, 0],
                                [-1, 0, 0], 1))
    sa.add_relative_motion(
        # pyre-fixme[6]: For 5th param expected `ndarray` but got `List[int]`.
        # pyre-fixme[6]: For 6th param expected `ndarray` but got `List[int]`.
        pybundle.RelativeMotion("1234", "1", "1234", "3", [0, 0, 0],
                                [0, -1, 0], 1))
    sa.add_relative_motion(
        # pyre-fixme[6]: For 5th param expected `ndarray` but got `List[int]`.
        # pyre-fixme[6]: For 6th param expected `ndarray` but got `List[int]`.
        pybundle.RelativeMotion("1234", "1", "1234", "4", [0, 0, 0],
                                [0, 0, -1], 1))
    sa.add_rig_instance_position_prior("1", [100, 0, 0], [1, 1, 1], "")
    sa.add_rig_instance_position_prior("2", [2, 0, 0], [1, 1, 1], "")
    sa.add_rig_instance_position_prior("3", [0, 2, 0], [1, 1, 1], "")

    sa.run()
    s1 = sa.get_rig_instance_pose("1")
    s2 = sa.get_rig_instance_pose("2")
    s3 = sa.get_rig_instance_pose("3")
    s4 = sa.get_rig_instance_pose("4")

    assert np.allclose(s1.translation, [0, 0, 0], atol=1e-6)
    assert np.allclose(s2.translation, [-2, 0, 0], atol=1e-6)
    assert np.allclose(s3.translation, [0, -2, 0], atol=1e-6)
    assert np.allclose(s4.translation, [0, 0, -2], atol=1e-6)
Beispiel #6
0
def test_pair_with_points_priors(bundle_adjuster) -> None:
    """Simple two rigs test with a point constraint for anchoring"""
    sa = bundle_adjuster
    sa.add_rig_instance(
        "1",
        # pyre-fixme[6]: For 1st param expected `ndarray` but got `List[float]`.
        # pyre-fixme[6]: For 2nd param expected `ndarray` but got `List[float]`.
        pygeometry.Pose([1e-3, 1e-3, 1e-3], [1e-3, 1e-3, 1e-3]),
        {"1": "cam1"},
        {"1": "rig_cam1"},
        False,
    )
    sa.add_rig_instance(
        "2",
        # pyre-fixme[6]: For 1st param expected `ndarray` but got `List[float]`.
        # pyre-fixme[6]: For 2nd param expected `ndarray` but got `List[float]`.
        pygeometry.Pose([1e-3, 1e-3, 1e-3], [1e-3, 1e-3, 1e-3]),
        {"2": "cam1"},
        {"2": "rig_cam1"},
        False,
    )
    sa.add_point("p1", [0, 0, 0], False)
    sa.add_point("p2", [0, 0, 0], False)

    sa.add_reconstruction("12", False)
    sa.add_reconstruction_instance("12", 4, "1")
    sa.add_reconstruction_instance("12", 4, "2")

    # identity rotation with pan/tilt/roll
    sa.add_absolute_roll("1", np.radians(90), 1)
    sa.add_absolute_pan("1", -np.radians(90), 1)
    sa.add_absolute_tilt("1", -np.radians(90), 1)

    sa.set_scale_sharing("12", True)
    sa.add_relative_motion(
        # pyre-fixme[6]: For 5th param expected `ndarray` but got `List[int]`.
        # pyre-fixme[6]: For 6th param expected `ndarray` but got `List[int]`.
        pybundle.RelativeMotion("12", "1", "12", "2", [0, 0, 0], [-1, 0, 0],
                                1))

    sa.add_point_projection_observation("1", "p1", [0, 0], 1)
    sa.add_point_projection_observation("2", "p1", [-0.5, 0], 1)
    sa.add_point_prior("p1", [-0.5, 2, 2], [1, 1, 1], True)

    sa.add_point_projection_observation("2", "p2", [0, 0], 1)
    sa.add_point_projection_observation("1", "p2", [0.5, 0], 1)
    sa.add_point_prior("p2", [1.5, 2, 2], [1, 1, 1], True)

    sa.run()
    s1 = sa.get_rig_instance_pose("1")
    s2 = sa.get_rig_instance_pose("2")
    r12 = sa.get_reconstruction("12")
    p1 = sa.get_point("p1")
    p2 = sa.get_point("p2")

    assert np.allclose(s1.translation, [0.5, -2, 2], atol=1e-2)
    assert np.allclose(s2.translation, [-1.5, -2, 2], atol=1e-2)
    assert np.allclose(p1.p, [-0.5, 2, 2], atol=1e-6)
    assert np.allclose(p2.p, [1.5, 2, 2], atol=1e-6)
    assert np.allclose(r12.get_scale("1"), 0.5)
    assert np.allclose(r12.get_scale("2"), 0.5)