在 Python 中使用 pye57 和 laspy 将 E57 转换为 LAS 的准确性问题

Conversion accuracy issues of E57 to LAS in Python using pye57 and laspy

提问人:Arjan 提问时间:10/17/2023 更新时间:10/18/2023 访问量:67

问:

我正在尝试将 .e57 点云转换为 .las 点云,但我遇到了似乎是由准确性引起的问题。下图说明了 CloudCompare 中的原始 .e57 与 CloudCompare 中转换后的 .las 文件进行了比较。点大小显著增加以比较差异。

原装 E57 enter image description here

转换后的 LAS enter image description here

如您所见,这些点在 LAS 文件中以某种格网模式定位。在 Potree 中检查 LAS 文件会在重要级别上暴露该问题。见下图。enter image description here

我用于将 E57 转换为 LAS 的代码发布在下面。如果有人对为什么会发生这种情况以及为什么这些点似乎是网格对齐的有任何见解,那么我很高兴听到更多。

import numpy as np
import pye57
import laspy

e57 = pye57.E57("in.e57")

# read scan at index 0
data = e57.read_scan(index=0, ignore_missing_fields=True, colors=True, intensity=True)

# 'data' is a dictionary with the point types as keys
assert isinstance(data["cartesianX"], np.ndarray)
assert isinstance(data["cartesianY"], np.ndarray)
assert isinstance(data["cartesianZ"], np.ndarray)

# other attributes can be read using:
# data = e57.read_scan(0, intensity=True, colors=True, row_column=True)
assert isinstance(data["cartesianX"], np.ndarray)
assert isinstance(data["cartesianY"], np.ndarray)
assert isinstance(data["cartesianZ"], np.ndarray)
assert isinstance(data["intensity"], np.ndarray)
assert isinstance(data["colorRed"], np.ndarray)
assert isinstance(data["colorGreen"], np.ndarray)
assert isinstance(data["colorBlue"], np.ndarray)

# the ScanHeader object wraps most of the scan information:
header = e57.get_header(0)
print(header.point_count)
print(header.rotation_matrix)
print(header.translation)

# all the header information can be printed using:
for line in header.pretty_print():
    print(line)

# Create a new LAS file
las_out = laspy.create(point_format=3, file_version='1.2')

# Populate the LAS file with point cloud data
print(data["cartesianX"])
las_out.x = data["cartesianX"]
las_out.y = data["cartesianY"]
las_out.z = data["cartesianZ"]
las_out.intensity = data["intensity"]
las_out.red = data["colorRed"]
las_out.green = data["colorGreen"]
las_out.blue = data["colorBlue"]

# Close the LAS file
las_out.write("output/out.las")

python-3.x 数据转换 浮精度 点云

评论


答:

0赞 Arjan 10/18/2023 #1

看来我在 LAS 标头中的缩放完全关闭了。浮点根据 LAS 标准四舍五入为整数,比例决定了精度。

我通过添加缩放和偏移标题解决了这个问题,如下所示

xmin = np.floor(np.min(data["cartesianX"]))
ymin = np.floor(np.min(data["cartesianY"]))
zmin = np.floor(np.min(data["cartesianZ"]))

las_out.header.offset = [xmin, ymin, zmin]
las_out.header.scale = [0.001, 0.001, 0.001]