예제 #1
0
def test_distortion():
    base = CameraModel.load_camera_default()
    lookat = np.array( (0.0, 0.0, 0.0) )
    up = np.array( (0.0, 0.0, 1.0) )

    cams = []
    cams.append(  base.get_view_camera(eye=np.array((1.0,0.0,1.0)),lookat=lookat,up=up) )

    distortion1 = np.array( [0.2, 0.3, 0.1, 0.1, 0.1] )
    cam_wide = CameraModel.load_camera_simple(name='cam_wide',
                                              fov_x_degrees=90,
                                              eye=np.array((-1.0,-1.0,0.7)),
                                              lookat=lookat,
                                              distortion_coefficients=distortion1,
                                              )
    cams.append(cam_wide)

    cam_ids = []
    for i in range(len(cams)):
        cams[i].name = 'cam%02d'%i
        cam_ids.append(cams[i].name)

    cam_system = MultiCameraSystem(cams)
    R = reconstruct.Reconstructor.from_pymvg(cam_system)
    for cam_id in cam_ids:
        nl_params = R.get_intrinsic_nonlinear(cam_id)
        mvg_cam = cam_system.get_camera_dict()[cam_id]
        assert np.allclose(mvg_cam.distortion, nl_params)
예제 #2
0
def _get_cams(with_distortion):
    base = CameraModel.load_camera_default()

    lookat = np.array((0.0, 0.0, 0.0))
    up = np.array((0.0, 0.0, 1.0))

    cams = []
    cams.append(
        base.get_view_camera(eye=np.array((1.0, 0.0, 1.0)),
                             lookat=lookat,
                             up=up))
    cams.append(
        base.get_view_camera(eye=np.array((1.2, 3.4, 5.6)),
                             lookat=lookat,
                             up=up))
    cams.append(
        base.get_view_camera(eye=np.array((0, 0.3, 1.0)), lookat=lookat,
                             up=up))

    if with_distortion:
        distortion1 = np.array([0.2, 0.3, 0.1, 0.1, 0.1])
    else:
        distortion1 = np.zeros((5, ))
    cam_wide = CameraModel.load_camera_simple(
        name='cam_wide',
        fov_x_degrees=90,
        eye=np.array((-1.0, -1.0, 0.7)),
        lookat=lookat,
        distortion_coefficients=distortion1,
    )
    cams.append(cam_wide)

    for i in range(len(cams)):
        cams[i].name = 'cam%02d' % i

    cam_system = MultiCameraSystem(cams)
    reconstructor = Reconstructor.from_pymvg(cam_system)
    result = dict(
        cams=cams,
        cam_system=cam_system,
        reconstructor=reconstructor,
    )
    return result
예제 #3
0
def build_example_system(n=6,z=5.0):
    base = CameraModel.load_camera_default()

    x = np.linspace(0, 2*n, n)
    theta = np.linspace(0, 2*np.pi, n)
    cams = []
    for i in range(n):
        # cameras are spaced parallel to the x axis
        center = np.array( (x[i], 0.0, z) )

        # cameras are looking at +y
        lookat = center + np.array( (0,1,0))

        # camera up direction rotates around the y axis
        up = -np.sin(theta[i]), 0, np.cos(theta[i])

        cam = base.get_view_camera(center,lookat,up)
        cam.name = 'theta: %.0f'%( np.degrees(theta[i]) )
        cams.append(cam)

    system = MultiCameraSystem(cams)
    return system
예제 #4
0
def build_example_system(n=6, z=5.0):
    base = CameraModel.load_camera_default()

    x = np.linspace(0, 2 * n, n)
    theta = np.linspace(0, 2 * np.pi, n)
    cams = []
    for i in range(n):
        # cameras are spaced parallel to the x axis
        center = np.array((x[i], 0.0, z))

        # cameras are looking at +y
        lookat = center + np.array((0, 1, 0))

        # camera up direction rotates around the y axis
        up = -np.sin(theta[i]), 0, np.cos(theta[i])

        cam = base.get_view_camera(center, lookat, up)
        cam.name = 'theta: %.0f' % (np.degrees(theta[i]))
        cams.append(cam)

    system = MultiCameraSystem(cams)
    return system