Open3d: register_key_callback doesn't work

Created on 10 Oct 2019  路  1Comment  路  Source: intel-isl/Open3D

Describe the bug
When I add a key using register_key_callback(key, callback), it doesn't work. Callback is not called when key is pressed. Also, the key encoding is not clear from the docs.

To Reproduce

import numpy as np
import open3d as o3d

def key_callback(vis):
    print('key')

points = np.random.rand(100000, 3)
point_cloud = o3d.PointCloud()
point_cloud.points = o3d.Vector3dVector(points)

vis = o3d.visualization.VisualizerWithKeyCallback()
vis.create_window()
vis.add_geometry(point_cloud)
vis.register_key_callback(41, key_callback)

vis.run()
vis.destroy_window()

Expected behavior
When I press A, which should be keycode 41, I expect 'key' to be printed. Also, when running and I hit H, I can see that the key is not registered under:

Keys registered for callback functions --
[)]
The default functions of these keys will be overridden.

Environment (please complete the following information):

  • OS: Ubuntu 16.04
  • Python version: 3.5.2
  • Open3D version: latest
  • Is this remote workstation?: no
  • How did you install Open3D?: pip3
question

Most helpful comment

We are using GLFW_KEY for register_key_callback function. Based on this document, a is 65.

The following code should work out of the box (with Open3D 0.9):

import numpy as np
import open3d as o3d

def key_callback(vis):
    print('key')

points = np.random.rand(100000, 3)
point_cloud = o3d.geometry.PointCloud()
point_cloud.points = o3d.utility.Vector3dVector(points)

vis = o3d.visualization.VisualizerWithKeyCallback()
vis.create_window()
vis.add_geometry(point_cloud)
vis.register_key_callback(65, key_callback)

vis.run()
vis.destroy_window()

>All comments

We are using GLFW_KEY for register_key_callback function. Based on this document, a is 65.

The following code should work out of the box (with Open3D 0.9):

import numpy as np
import open3d as o3d

def key_callback(vis):
    print('key')

points = np.random.rand(100000, 3)
point_cloud = o3d.geometry.PointCloud()
point_cloud.points = o3d.utility.Vector3dVector(points)

vis = o3d.visualization.VisualizerWithKeyCallback()
vis.create_window()
vis.add_geometry(point_cloud)
vis.register_key_callback(65, key_callback)

vis.run()
vis.destroy_window()
Was this page helpful?
0 / 5 - 0 ratings

Related issues

DKandrew picture DKandrew  路  4Comments

mike239x picture mike239x  路  3Comments

HaiyongJiang picture HaiyongJiang  路  3Comments

blackccpie picture blackccpie  路  3Comments

DKandrew picture DKandrew  路  3Comments