我正在尝试在python中使用Open3D库来绘制3D模型。我的问题是我无法更新相机的固有属性。我想知道如何做-如果可能的话。当前使用默认的相机参数。
rgbd_image = o3d.geometry.RGBDImage.create_from_tum_format(color_raw, depth_raw)
a = o3d.camera.PinholeCameraIntrinsicParameters
pcd = o3d.geometry.PointCloud.create_from_rgbd_image(
rgbd_image,
o3d.camera.PinholeCameraIntrinsic(
o3d.camera.PinholeCameraIntrinsicParameters.Kinect2DepthCameraDefault))
# Flip it, otherwise the pointcloud will be upside down
pcd.transform([[1, 0, 0, 0], [0, -1, 0, 0], [0, 0, -1, 0], [0, 0, 0, 1]])
o3d.visualization.draw_geometries([pcd])
我想将固有矩阵更新为[3131.58 0.00 1505.62,0.00 3131.58 2004.13,0.00 0.00 1.00]
谢谢。
答案 0 :(得分:1)
您必须声明一个 open3d.camera.PinholeCameraIntrinsic
对象,然后使用所需的中间矩阵对其进行初始化,如下所示:
cam = o3d.camera.PinholeCameraIntrinsic()
cam.intrinsic_matrix = [[3131.58, 0.00, 1505.62] , [0.00, 3131.58, 2004.13], [0.00, 0.00, 1.00]]
然后,您可以像这样将对象传递给 create_point_cloud_from_rgbd_image
方法:
pcd = o3d.geometry.create_point_cloud_from_rgbd_image(rgbd_image,cam)
注意
您可以使用其非默认构造函数初始化 cam
对象以指定其宽度和高度,如下所示:
cam = o3d.camera.PinholeCameraIntrinsic(W, H, Fx, Fy, Cx, Cy)
编辑
经过一番搜索,我发现最好像这样初始化参数,以便能够同时定义内在和外在矩阵:
intrinsic = o3d.camera.PinholeCameraIntrinsic(w, h, fx,fy, cx, cy)
intrinsic.intrinsic_matrix = [[fx, 0, cx], [0, fy, cy], [0, 0, 1]]
cam = o3d.camera.PinholeCameraParameters()
cam.intrinsic = intrinsic
cam.extrinsic = np.array([[0., 0., 0., 0.], [0., 0., 0., 0.], [0., 0., 0., 0.], [0., 0., 0., 1.]])
pcd = o3d.geometry.create_point_cloud_from_rgbd_image(
rgbd_image, cam.intrinsic, cam.extrinsic)