save
是Open3D中的一个核心类open3d.core.HashMap
的成员函数,用于将一个open3d.core.HashMap
对象保存为二进制文件。
def save(self, filename: str, binary=True, compressed=True) -> bool
filename
:字符串类型,要保存的文件名(包括路径)。binary
:布尔类型,可选参数,是否将数据以二进制形式保存。默认为True
。compressed
:布尔类型,可选参数,是否将数据进行压缩后保存。默认为True
。True
;否则,返回False
。import open3d.core as o3c
# 创建一个HashMap对象
hm = o3c.HashMap()
# 添加数据
hm[o3c.Tensor([1, 2, 3])] = o3c.Tensor([4, 5, 6])
hm[o3c.Tensor([4, 5, 6])] = o3c.Tensor([7, 8, 9])
# 保存HashMap对象
success = hm.save("my_hashmap.bin")
if success:
print("HashMap保存成功!")
else:
print("HashMap保存失败!")
save
函数保存的文件是.bin
格式的二进制文件,因此如果要查看保存的数据内容,需要使用二进制文件读取函数,如numpy.fromfile
等。open3d.core.HashMap.load
函数。