python讀寫自定義格式的pcd文件的示例代碼
lio-sam中pose是按照x y z i roll pitch yaw time 存儲的,需要用python讀取或者保存。
讀pcd
from lidar_mapping.tools import py3pcd
import numpy as np
from scipy.spatial.transform import Rotation as R
def read_transformations(filename: str):
pc = py3pcd.PointCloud.from_path(filename)
data = pc.pc_data.view(
np.dtype([
("x", np.float32),
("y", np.float32),
("z", np.float32),
("intensity", np.float32),
("roll", np.float32),
("pitch", np.float32),
("yaw", np.float32),
("time", np.float64)
])
).reshape(-1, 1)
return data寫pcd
import numpy as np
from lidar_mapping.tools import py3pcd
# 創(chuàng)建一個包含點云數(shù)據(jù)的numpy array
point_cloud = np.array([
[1.0, 2.0, 3.0, 0.5, 0.1, 0.2, 0.3, 1234567890.1],
[4.0, 5.0, 6.0, 0.6, 0.4, 0.5, 0.6, 1234567900.24]],
dtype=np.dtype([
("x", np.float32),
("y", np.float32),
("z", np.float32),
("intensity", np.float32),
("roll", np.float32),
("pitch", np.float32),
("yaw", np.float32),
("time", np.float64)
])
)
pcl_data = py3pcd.PointCloud.from_array(point_cloud)
pcl_data.save_pcd('point_cloud.pcd', compression='binary')到此這篇關(guān)于python讀寫自定義格式的pcd文件的文章就介紹到這了,更多相關(guān)python讀寫pcd文件內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
分享python數(shù)據(jù)統(tǒng)計的一些小技巧
今天這些小技巧在處理python的一些數(shù)據(jù)方面還是很有幫助的,希望能幫到在這方面有需要的童鞋~2016-07-07
淺談Python實現(xiàn)opencv之圖片色素的數(shù)值運算和邏輯運算
今天帶大家來學(xué)習(xí)的是關(guān)于Python的相關(guān)知識,文章圍繞著圖片色素的數(shù)值運算和邏輯運算展開,文中有非常詳細(xì)的的介紹及代碼示例,需要的朋友可以參考下2021-06-06
Python基礎(chǔ)學(xué)習(xí)列表+元組+字典+集合
這篇文章主要介紹了Python基礎(chǔ)學(xué)習(xí)列表+元組+字典+集合,文章接上一篇內(nèi)容學(xué)習(xí),主要針對python零基礎(chǔ)的同學(xué),感興趣的話就學(xué)起來吧2022-05-05
詳解pytorch tensor和ndarray轉(zhuǎn)換相關(guān)總結(jié)
這篇文章主要介紹了詳解pytorch tensor和ndarray轉(zhuǎn)換相關(guān)總結(jié),文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2020-09-09
Python實現(xiàn)常見坐標(biāo)系的相互轉(zhuǎn)換
WGS84坐標(biāo)系、GCJ02坐標(biāo)系、BD09坐標(biāo)系和Web?墨卡托投影坐標(biāo)系是我們常見的四個坐標(biāo)系。這篇文章為大家整理了這四個坐標(biāo)系之間相互轉(zhuǎn)換的方法,需要的可以參考一下2023-02-02

