Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VoxelGrid.voxels.append() does not append #1101

Closed
SilvioJin opened this issue Aug 5, 2019 · 1 comment
Closed

VoxelGrid.voxels.append() does not append #1101

SilvioJin opened this issue Aug 5, 2019 · 1 comment

Comments

@SilvioJin
Copy link

IMPORTANT: Please use the following template to report the bug.


Describe the bug
open3d.geometry.VoxelGrid.voxels.append(voxel) does not append the voxel object or any other object.

My goal is to create a VoxelGrid object from a numpy array of shape (128,128,128).

To Reproduce

import open3d as o3d
import numpy as np

vg = o3d.geometry.VoxelGrid()
vox = o3d.geometry.Voxel()
vox.grid_index = np.array([  7,  59, 101])
vg.voxels.append(vox)

but print(vg.voxels) just returns []
and of course print(vg.has_voxels) says <bound method PyCapsule.has_voxels of geometry::VoxelGrid with 0 voxels.>

Expected behavior
vg.voxels should contain the Voxel object

Environment (please complete the following information):

  • OS: OSX Mojave 10.14.5
  • Python version: 3.6.5
  • Open3D version: 0.7.0.0
  • Is this remote workstation?: no
  • How did you install Open3D?: conda
@SilvioJin SilvioJin added the bug label Aug 5, 2019
@griegler
Copy link
Contributor

That seems to be a limitation of pybind11. As the VoxelGrid class is subject to some changes anyway it might not be worth to implement a fix atm.
What you can however do to achieve your goal is to first collect all voxels in a Python list, and then assign this list to the VoxelGrid

voxels = []
vox = o3d.geometry.Voxel()
vox.grid_index = np.array([  7,  59, 101])
voxels.append(vox)
vg.voxels = voxels

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants