Open3d: rotated numpy array cannot be converted back into open3d.PointCloud

Created on 1 Apr 2019  路  5Comments  路  Source: intel-isl/Open3D

The Issue
I am currently loading in the standard ply bunny as an open3d.PointCloud. Then I convert this to a numpy array using open3d's builtin method described in the documentation. Then I rotate the numpy array 90 degrees using the built in numpy method np.rot90. After this step, when I try to convert back to an open3d.PointCloud, it fails with a runtime error

To Reproduce
Here is the code that reproduces the problem, I will even attach the bunny.ply file I'm using (NOTE: they don't accept PLY files so I uploaded it in txt form, should be able to just change the filename extension back to ply)

import os
import open3d
import numpy as np

# load in bunny and rotate it 90 deg
input_file = os.path.join('data', 'bunny', 'bunny.ply')
bny = open3d.read_point_cloud(input_file)
bnynp = np.asarray(bny.points)
bny_rtd = np.rot90(bnynp)

# create new pointcloud to load out rotated bunny into
new_bny = open3d.PointCloud()
new_bny.points = open3d.Vector3dVector(bny_rtd)
---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
<ipython-input-16-cd011cae2d61> in <module>
----> 1 new_bny.points = open3d.Vector3dVector(bny_rtd)

RuntimeError:

bunny.txt

Environment

  • OS: Ubuntu 16.04
  • Python version: 3.5.2
  • Open3D version: 0.5.0.0
  • Is this remote workstation?: no
  • How did you install Open3D?: pip
possible bug

All 5 comments

same things happens if I use scipy.ndimage.rotate instead of np.rot90

After rotation, the nump array might not be of shape (n, 3).
open3d.Vector3dVector()'s input should have shape (n, 3) (see docs).

If you're trying to rotate the point cloud, try open3d.geometry.PointCloud.transform() (see docs), i.e.
new_bny.transform(rotation_matrix)

You were right that those previous functions were outputting the wrong shape for converting back into a open3d.PointCloud. I have read through the documentation on open3d.geometry.PointCloud.transform() and it seems to be what I'm looking for, but can you explain a but more what the [4x4] transformation matrix looks like?

Thanks you for you time, very exciting project and to see it integrated with PointNet++

See http://mathworld.wolfram.com/RotationMatrix.html

In Open3D, pad the 3x3 matrix to 4x4 matrix by inserting a 1 at the last diaganal position. For example, to rotate along x-axis, where (x', y', z') is the transformed point.

CodeCogsEqn

You may also refer to the implementation: https://github.com/IntelVCL/Open3D/blob/519c69333130c1b9c252227b43436089b9ba6ce1/src/Open3D/Geometry/PointCloud.cpp#L88-L101

thanks for you help and patience with this, I wlll close the issue and reopen if I have any other questions

Was this page helpful?
0 / 5 - 0 ratings