open3d voxel_size too small : down sampling not working for e57 binaries

1.7k Views Asked by At

I'm trying to downsample a point cloud. I have 2 data formats for different parts of my data. The .bin files cause no problems, but when I'm trying to downsample the .e57 files I encounter a strange problem. Here's what I do:

import numpy as np
import open3d

pointfile = "path/to/file.e57"
pcd_data = np.fromfile(point_file, dtype=np.float32)
pcd_data = velo_data.reshape(-1, 4)
pcd_points = velo_data[:, :3]

pcd = open3d.geometry.PointCloud()
pcd.points = open3d.utility.Vector3dVector(pcd_points)
pcd_down = pcd.voxel_down_sample(voxel_size=0.8)
res = np.asarray(pcd_down.points)

It works fine for .bin, but when i try the .e57 I get the error:

RuntimeError: [Open3D ERROR] [VoxelDownSample] voxel_size is too small.

No matter if I use voxel_size of 0.005, 0.8, 100, 5000 or 1000000000000000.

I tried the earlier open3d Version:

pcd_down = open3d.geometry.voxel_down_sample(voxel_size=0.8)

and at least it throws no error, but my downsampled pointcloud then contains 0 points (from ~350 000).

As the file should be structured in points with 4 features, the file seems to be read correctly (this works for any of my files), as the reshape works just fine.

Any ideas?

1

There are 1 best solutions below

0
On

Still have no clue about the original error, but I succesfully worked around the problem by using pye57: https://github.com/davidcaron/pye57 together with this solution to a possibly occuring problem: https://github.com/davidcaron/pye57/issues/6#issuecomment-803894677

With this code

import numpy as np
import open3d
import pye57

point_file = "path/to/file.e57"

e57 = pye57.E57(point_file)
data = e57.read_scan_raw(0)
assert isinstance(data["cartesianX"], np.ndarray)
assert isinstance(data["cartesianY"], np.ndarray)
assert isinstance(data["cartesianZ"], np.ndarray)

x = np.array(data["cartesianX"])
y = np.array(data["cartesianY"])
z = np.array(data["cartesianZ"])

pcd_points = np.concatenate((x, y), axis=0)
pcd_points = np.concatenate((pcd_points, z), axis=0)
pcd_points = velo_points.reshape(-1, 3)

pcd = open3d.geometry.PointCloud()
pcd.points = open3d.utility.Vector3dVector(pcd_points)
pcd_down = pcd.voxel_down_sample(voxel_size=0.0035)

I finally get a downsampled point cloud.