open3d例程

Open3D是一个可以支持 3D数据处理软件快速开发的开源库。简要介绍下其例程。

综合场景

Open3D能集成所有RGB-D图像到单一TSDF volume,压缩为一个mesh

输入参数

if __name__ =="__main__":

    parser =argparse.ArgumentParser(description=

            "integrate the whole RGBDsequence using estimated camera pose")

   parser.add_argument("path_dataset", help="path to thedataset")

   parser.add_argument("-path_intrinsic",

            help="path to the RGBD cameraintrinsic")

    args = parser.parse_args()

 

    if args.path_intrinsic:

        intrinsic =read_pinhole_camera_intrinsic(args.path_intrinsic)

    else:

        intrinsic =PinholeCameraIntrinsic.prime_sense_default

   scalable_integrate_rgb_frames(args.path_dataset, intrinsic)

 

上述脚本在python integrate_scene.py文件中,-path_intrinsic 指定json文件的路径,

 

集成RGBD frames

defscalable_integrate_rgb_frames(path_dataset, intrinsic):

    [color_files, depth_files] =get_rgbd_file_lists(path_dataset)

    n_files = len(color_files)

    n_frames_per_fragment = 100

    n_fragments = int(math.ceil(float(n_files)/ n_frames_per_fragment))

    volume = ScalableTSDFVolume(voxel_length =3.0 / 512.0,

            sdf_trunc = 0.04, with_color =True)

 

    pose_graph_fragment = read_pose_graph(

            path_dataset +template_global_posegraph_optimized)

 

    for fragment_id inrange(len(pose_graph_fragment.nodes)):

        pose_graph_rgbd =read_pose_graph(path_dataset +

               template_fragment_posegraph_optimized % fragment_id)

 

        for frame_id inrange(len(pose_graph_rgbd.nodes)):

            frame_id_abs = fragment_id *n_frames_per_fragment + frame_id

            print("Fragment %03d / %03d ::integrate rgbd frame %d (%d of %d)."

                    % (fragment_id,n_fragments-1, frame_id_abs, frame_id+1,

                   len(pose_graph_rgbd.nodes)))

            color =read_image(color_files[frame_id_abs])

            depth =read_image(depth_files[frame_id_abs])

            rgbd =create_rgbd_image_from_color_and_depth(color, depth,

                    depth_trunc = 3.0,convert_rgb_to_intensity = False)

            pose =np.dot(pose_graph_fragment.nodes[fragment_id].pose,

                   pose_graph_rgbd.nodes[frame_id].pose)

            volume.integrate(rgbd, intrinsic,np.linalg.inv(pose))

 

    mesh = volume.extract_triangle_mesh()

    mesh.compute_vertex_normals()

    draw_geometries([mesh])

 

    mesh_name = path_dataset +template_global_mesh

    write_triangle_mesh(mesh_name, mesh, False,True)

这个函数先读取基准结果,然后计算RBGD图像在全局空间的位置。
open3d的使用说明,参见https://www.toutiao.com/i6528559343925723661/

  • 1
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值