vispy 显示 kitti 点云数据
(感谢前辈)转自: https://zhuanlan.zhihu.com/p/74181054
评价:vispy显示三维点云数据很流畅,但是显示的点好像有点失真的感觉。
Vispy官方例程:
http://vispy.org/gallery.html
import numpy as np
import vispy.scene
from vispy.scene import visuals
import sys
# Make a canvas and add simple view
canvas = vispy.scene.SceneCanvas(keys='interactive', show=True)
view = canvas.central_widget.add_view()
# # generate data 使用随机数据的话把这块反注释掉
# pos = np.random.normal(size=(100000, 3), scale=0.2)
# # one could stop here for the data generation, the rest is just to make the
# # data look more interesting. Copied over from magnify.py
# centers = np.random.normal(size=(50, 3))
# indexes = np.random.normal(size=100000, loc=centers.shape[0]/2.,
# scale=centers.shape[0]/3.)
# indexes = np.clip(indexes, 0, centers.shape[0]-1).astype(int)
# scales = 10**(np.linspace(-2, 0.5, centers.shape[0]))[indexes][:, np.newaxis]
# pos *= scales
# pos += centers[indexes]
# scatter = visuals.Markers()
# scatter.set_data(pos, edge_color=None, face_color=(1, 1, 1, .5), size=5)
# 使用 kitti 数据, n*3
img_id = 17 # 2,3 is not able for pcl;
path = r'D:\KITTI\Object\training\velodyne\%06d.bin' % img_id ## Path ## need to be changed
points = np.fromfile(path, dtype=np.float32).reshape(-1, 4)
# create scatter object and fill in the data
scatter = visuals.Markers()
scatter.set_data(points[:,:3], edge_color=None, face_color=(1, 1, 1, .5), size=5)
view.add(scatter)
view.camera = 'turntable' # or try 'arcball'
# add a colored 3D axis for orientation
axis = visuals.XYZAxis(parent=view.scene)
if __name__ == '__main__':
if sys.flags.interactive != 1:
vispy.app.run()
效果如如下,比pcl 显示效果略微差点,但是十多万个点滚动也很流畅:
发布者:全栈程序员-用户IM,转载请注明出处:https://javaforall.cn/2172.html原文链接:https://javaforall.cn
【正版授权,激活自己账号】: Jetbrains全家桶Ide使用,1年售后保障,每天仅需1毛
【官方授权 正版激活】: 官方授权 正版激活 支持Jetbrains家族下所有IDE 使用个人JB账号...