open3d.io.write_pinhole_camera_parameters(filename, camera)
该函数将给定的针孔相机参数对象(camera)保存为,相机参数格式(.json)文件(filename)。
该函数没有返回值。
import open3d as o3d
# 创建默认的针孔相机参数对象
cam_params = o3d.camera.PinholeCameraParameters()
print("默认相机参数:\n", cam_params.intrinsic)
# 将相机参数保存为json格式文件
o3d.io.write_pinhole_camera_parameters("./cam_params.json", cam_params)
# 加载json格式文件,并创建针孔相机参数对象
cam_params = o3d.io.read_pinhole_camera_parameters("./cam_params.json")
print("保存的相机参数:\n", cam_params.intrinsic)
import numpy as np
import open3d as o3d
# 创建针孔相机参数对象
intrinsic = o3d.camera.PinholeCameraIntrinsic(
o3d.camera.PinholeCameraIntrinsicParameters.PrimeSenseDefault)
extrinsic = np.eye(4)
cam_params = o3d.camera.PinholeCameraParameters()
cam_params.intrinsic = intrinsic
cam_params.extrinsic = extrinsic