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

Fix VoxelGrid.voxels bug #1535 #1688

Merged
merged 1 commit into from
Apr 12, 2020
Merged

Conversation

kosuke55
Copy link
Contributor

@kosuke55 kosuke55 commented Apr 7, 2020

I found a bug that can't use open3d.geometry.VoxelGrid.voxels same as #1535 .
Thanks to @noahstier, I changed to get voxels of unordered_map by function.

Without this PR

In [11]: voxel_grid.voxels
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-11-d7484a89cc11> in <module>()
----> 1 voxel_grid.voxels

TypeError: unhashable type: 'numpy.ndarray'

With this PR

In [11]:: voxel_grid.get_voxels()
[geometry::Voxel with grid_index: (16, 25, 12), color: (0.6, 0.654902, 0.623529),                                                                                                                                                     
 geometry::Voxel with grid_index: (27, 66, 22), color: (0.0666667, 0.0784314, 0.0745098),                                                                                                                                             
 geometry::Voxel with grid_index: (18, 12, 9), color: (0.660392, 0.697255, 0.680784),                                                                                                                                                 
 
...

This change is Reviewable

@update-docs
Copy link

update-docs bot commented Apr 7, 2020

Thanks for submitting this pull request! The maintainers of this repository would appreciate if you could update the CHANGELOG.md based on your changes.

Copy link
Contributor

@griegler griegler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this PR. Travis is failing because of the style check. Please see http://www.open3d.org/docs/release/contribute.html#automated-style-checker and run make apply-style.

Reviewed 3 of 3 files at r1.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @kosuke55)


src/Open3D/Geometry/VoxelGrid.h, line 240 at r1 (raw file):

            const Eigen::Vector3d &max_bound);

    std::vector<Voxel> Voxels();
  • GetVoxels instead of Voxels would be more consistent with the naming scheme.
  • Please add documentation. For an example see the method CreateFromTriangleMeshWithinBounds above.
  • Can we make this method const

src/Python/open3d_pybind/geometry/voxelgrid.cpp, line 89 at r1 (raw file):

            .def(py::self += py::self)
            .def("voxels", &geometry::VoxelGrid::Voxels,
                           "List of ``Voxel``: Voxels contained in voxel grid")

I think it would be good to mention that changes to the voxels returned from this method are not reflected in the voxel grid.

@kosuke55
Copy link
Contributor Author

kosuke55 commented Apr 8, 2020

@griegler
Thank you for the review. Please check it again because I fixed.

Copy link
Contributor

@griegler griegler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 3 of 3 files at r2.
Reviewable status: all files reviewed, 3 unresolved discussions (waiting on @kosuke55)


src/Open3D/Geometry/VoxelGrid.h, line 242 at r2 (raw file):

    // Returns List of ``Voxel``: Voxels contained in voxel grid.
    // Changes to the voxels returned from this method
    // are not reflected in the voxel grid.

The doc is already better, but could you please format it in the style of the example below:

    /// Creates a VoxelGrid from a given TriangleMesh. No color information is
    /// converted. The bounds of the created VoxelGrid are defined by the given
    /// parameters..
    ///
    /// \param input The input TriangleMesh.
    /// \param voxel_size Voxel size of of the VoxelGrid construction.
    /// \param min_bound Minimum boundary point for the VoxelGrid to create.
    /// \param max_bound Maximum boundary point for the VoxelGrid to create.

@kosuke55
Copy link
Contributor Author

@griegler
I added one more / to the doc.

Copy link
Contributor

@griegler griegler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 1 of 1 files at r3.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved

@yxlao yxlao merged commit c513cd0 into isl-org:master Apr 12, 2020
@amisaw
Copy link

amisaw commented Jun 2, 2020

Hi, I have pulled the latest version of the master branch and I'm still having this error when trying to use np.asarray(vox_grid.voxels)) or vox_grid.voxels
TypeError: unhashable type: 'numpy.ndarray'.

Any suggestions?

@kosuke55
Copy link
Contributor Author

kosuke55 commented Jun 2, 2020

@amisaw
In this PR, voxels is deprecated and can now be retrieved by get_voxels() instead.
If you have the latest version, please do

voxel_grid.get_voxels()

@amisaw
Copy link

amisaw commented Jun 2, 2020

Thanks for the response! However when I try voxel_grid.get_voxels(), I get this error:
*** AttributeError: 'open3d.open3d.geometry.VoxelGrid' object has no attribute 'get_voxels'

Note: I have pulled the latest version of Master. I also tried checking out the c513cd0 commit but I'm still getting the above error. Any suggestions?

@kosuke55 kosuke55 deleted the hotfix/voxels branch June 2, 2020 16:32
@noahstier
Copy link
Contributor

noahstier commented Jun 2, 2020 via email

@kosuke55 kosuke55 restored the hotfix/voxels branch June 2, 2020 16:38
@amisaw
Copy link

amisaw commented Jun 2, 2020 via email

@kosuke55
Copy link
Contributor Author

kosuke55 commented Jun 2, 2020

@amisaw
This is another issue, version 0.10.0 does not support ubuntu16.04 like #1898
To use get_voxels() on 16.04, go back to the past commit or use my branch.

@amisaw
Copy link

amisaw commented Jun 3, 2020 via email

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

Successfully merging this pull request may close these issues.

5 participants