当前位置: 首页>>代码示例>>Python>>正文


Python CameraModel.load_camera_from_file方法代码示例

本文整理汇总了Python中pymvg.camera_model.CameraModel.load_camera_from_file方法的典型用法代码示例。如果您正苦于以下问题:Python CameraModel.load_camera_from_file方法的具体用法?Python CameraModel.load_camera_from_file怎么用?Python CameraModel.load_camera_from_file使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pymvg.camera_model.CameraModel的用法示例。


在下文中一共展示了CameraModel.load_camera_from_file方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: check_distortion_yamlfile_roundtrip

# 需要导入模块: from pymvg.camera_model import CameraModel [as 别名]
# 或者: from pymvg.camera_model.CameraModel import load_camera_from_file [as 别名]
def check_distortion_yamlfile_roundtrip(cam_opts):
    """check that roundtrip of camera model to/from a yaml file works"""
    cam = _build_test_camera(**cam_opts)
    fname = tempfile.mktemp(suffix='.yaml')
    cam.save_intrinsics_to_yamlfile(fname)
    try:
        cam2 = CameraModel.load_camera_from_file( fname, extrinsics_required=False )
    finally:
        os.unlink(fname)

    distorted = np.array( [[100.0,100],
                           [100,200],
                           [100,300],
                           [100,400]] )
    orig_undistorted = cam.undistort( distorted )
    reloaded_undistorted = cam2.undistort( distorted )
    assert np.allclose( orig_undistorted, reloaded_undistorted )
开发者ID:thinkerahead,项目名称:pymvg,代码行数:19,代码来源:test_camera_model.py

示例2: _build_test_camera

# 需要导入模块: from pymvg.camera_model import CameraModel [as 别名]
# 或者: from pymvg.camera_model.CameraModel import load_camera_from_file [as 别名]
def _build_test_camera(**kwargs):
    o = Bunch(**kwargs)
    if not kwargs.get('at_origin',False):
        translation = geometry_msgs.msg.Point()
        translation.x = 0.273485679077
        translation.y = 0.0707310128808
        translation.z = 0.0877802104531

        rotation = geometry_msgs.msg.Quaternion()
        rotation.x = 0.309377331102
        rotation.y = 0.600893485738
        rotation.z = 0.644637681813
        rotation.w = 0.357288321925
    else:
        translation = geometry_msgs.msg.Point()
        translation.x = 0.0
        translation.y = 0.0
        translation.z = 0.0

        rotation = geometry_msgs.msg.Quaternion()
        rotation.x = 0.0
        rotation.y = 0.0
        rotation.z = 0.0
        rotation.w = 1.0

    if 'from_file' in kwargs:
        if kwargs['type']=='ros':
            cam = CameraModel.load_camera_from_file( fname=kwargs['filename'],
                                                     extrinsics_required=False )
            i = cam.get_intrinsics_as_bunch()
            cam = CameraModel._from_parts(
                              translation=point_msg_to_tuple(translation),
                              rotation=parse_rotation_msg(rotation),
                              intrinsics=i,
                              name='cam',
                              )
        elif kwargs['type']=='pymvg':
            del translation
            del rotation
            system = MultiCameraSystem.from_pymvg_file(fname=kwargs['filename'])
            names = system.get_names()

            names.sort()
            name = names[0] # get first camera from system
            cam = system._cameras[name]

            rotation = cam.get_extrinsics_as_bunch().rotation
            translation = cam.get_extrinsics_as_bunch().translation
        else:
            raise ValueError('unknown file type')

    else:

        if o.ROS_test_data:
            i = sensor_msgs.msg.CameraInfo()
            # these are from image_geometry ROS package in the utest.cpp file
            i.height = 480
            i.width = 640
            i.distortion_model = 'plumb_bob'
            i.D = [-0.363528858080088, 0.16117037733986861, -8.1109585007538829e-05, -0.00044776712298447841, 0.0]
            i.K = [430.15433020105519,                0.0, 311.71339830549732,
                                         0.0, 430.60920415473657, 221.06824942698509,
                                         0.0,                0.0,                1.0]
            i.R = [0.99806560714807102, 0.0068562422224214027, 0.061790256276695904,
                          -0.0067522959054715113, 0.99997541519165112, -0.0018909025066874664,
                          -0.061801701660692349, 0.0014700186639396652, 0.99808736527268516]
            i.P = [295.53402059708782, 0.0, 285.55760765075684, 0.0,
                          0.0, 295.53402059708782, 223.29617881774902, 0.0,
                          0.0, 0.0, 1.0, 0.0]
        else:
            i = sensor_msgs.msg.CameraInfo()
            i.height = 494
            i.width = 659
            i.distortion_model = 'plumb_bob'
            i.D = [-0.34146457767225, 0.196070795764995, 0.000548988393912233, 0.000657058395082583, -0.0828776806503243]
            i.K = [516.881868241566, 0.0, 333.090936517613, 0.0, 517.201263180996, 231.526036849886, 0.0, 0.0, 1.0]
            i.R = [1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0]
            i.P = [442.17529296875, 0.0, 334.589001099812, 0.0, 0.0, 474.757141113281, 228.646131377705, 0.0, 0.0, 0.0, 1.0, 0.0]

        cam = CameraModel._from_parts(
                          translation=point_msg_to_tuple(translation),
                          rotation=parse_rotation_msg(rotation),
                          intrinsics=i,
                          name='cam',
                          )
    if kwargs.get('flipped',False):
        cam = cam.get_flipped_camera()
    if kwargs.get('get_input_data',False):
        return dict(cam=cam,
                    translation=translation,
                    rotation=rotation,
                    )
    return cam
开发者ID:thinkerahead,项目名称:pymvg,代码行数:95,代码来源:utils.py


注:本文中的pymvg.camera_model.CameraModel.load_camera_from_file方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。