Nit
Nit

Reputation: 23

Update camera intrinsic parameter in open3d-python

I am trying to use Open3D library in python to plot a 3D model. My issue is that I am not able to update the camera intrinsic properties. I would like to know how to do it - if its possible. Currently its using default camera parameters.

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])

I would like to update the intrinsic matrix to [3131.58 0.00 1505.62 , 0.00 3131.58 2004.13, 0.00 0.00 1.00]

Thanks.

Upvotes: 2

Views: 8036

Answers (1)

Mostafa Wael
Mostafa Wael

Reputation: 3838

You have to declare an open3d.camera.PinholeCameraIntrinsic object then, initialize it with the required intersic matrix like this:

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]]

then, you can pass the object to the create_point_cloud_from_rgbd_image method like this:

pcd = o3d.geometry.create_point_cloud_from_rgbd_image(rgbd_image,cam)

N.B.

You could initialize the cam object using its non-default constructor to specify its width and height, like this:

cam = o3d.camera.PinholeCameraIntrinsic(W, H, Fx, Fy, Cx, Cy)

EDIT

After some search, I found that it's better to initialize the parameters like this, to be able to define both the intrinsic and the extrinsic matrices:

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)

Upvotes: 4

Related Questions