Mr. Randy Tom
Mr. Randy Tom

Reputation: 331

Visualizing point cloud with open3d

I'm using the following code to visualize the point cloud.

import open3d as o3d
pcd = o3d.io.read_point_cloud("assets/pcd.ply")

o3d.visualization.draw_geometries([pcd],lookat=[2.6172, 2.0475, 1.532],)

Unfortunately, I'm getting the following error

Traceback (most recent call last):
  File "/home/app/pointcloud.py", line 5, in <module>
    o3d.visualization.draw_geometries([pcd],lookat=[2.6172, 2.0475, -0.4])
TypeError: draw_geometries(): incompatible function arguments. The following argument types are supported:
    1. (geometry_list: List[open3d.open3d_pybind.geometry.Geometry], window_name: str = 'Open3D', width: int = 1920, height: int = 1080, left: int = 50, top: int = 50, point_show_normal: bool = False, mesh_show_wireframe: bool = False, mesh_show_back_face: bool = False) -> None

Invoked with: [geometry::PointCloud with 677248 points.]; kwargs: lookat=[2.6172, 2.0475, -0.4]

am I missing something?

Upvotes: 2

Views: 3878

Answers (2)

saurabheights
saurabheights

Reputation: 4574

I am not sure on Open3D version 3 years ago, but there is draw_geometries variant which accepts lookat variable now. The pybind code to generate python bindings is here but notice that it is necessary to pass all 4 variables: front, lookat, up, zoom.

o3d.visualization.draw_geometries(
            geometries,
            front=[0.4699189535486108, -0.62764022425775134, 0.62068021233921933],
            lookat=[ -0.97243714332580566, -0.1751408576965332, 0.51464511454105377 ],
            up=[ -0.36828927493940194, 0.49961995188329117, 0.78405542766104697 ],
            zoom=0.15999999999999961,
        )

Tip - Above values are first generated by executing o3d.visualization.draw_geometries(geometries,), setting camera position and then pressing Ctrl + C which copies View control settings. A sample output is:-

{
    "class_name" : "ViewTrajectory",
    "interval" : 29,
    "is_loop" : false,
    "trajectory" : 
    [
        {
            "boundingbox_max" : [ 3.0492053031921387, 6.549717903137207, 1.4599999189376831 ],
            "boundingbox_min" : [ -4.99407958984375, -6.8999996185302734, -0.43070968985557556 ],
            "field_of_view" : 60.0,
            "front" : [ 0.0, 0.0, 1.0 ],
            "lookat" : [ -0.97243714332580566, -0.1751408576965332, 0.51464511454105377 ],
            "up" : [ 0.0, 1.0, 0.0 ],
            "zoom" : 0.69999999999999996
        }
    ],
    "version_major" : 1,
    "version_minor" : 0
}

Upvotes: 1

Hanxiao Jiang
Hanxiao Jiang

Reputation: 90

There is no lookat parameter in the draw_geometries function. You can simply visualize without that parameter

The deeper reason for the error is caused by the mismatched version open3D. For the lastest version, some parameters and functions have been modified.

Upvotes: 2

Related Questions