今天在ubutnu 18.04上装了mayavi, 但是写代码可视化点云的时候出现了下面的情况:

QLibraryPrivate::loadPlugin failed on "/home/eric/anaconda3/envs/pointnet/lib/python3.6/site-packages/PyQt5/Qt/plugins/platforms/libqxcb.so" : "Cannot load library /home/eric/anaconda3/envs/pointnet/lib/python3.6/site-packages/PyQt5/Qt/plugins/platforms/libqxcb.so: (libxcb-xinerama.so.0: cannot open shared object file: No such file or directory)"
qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "" even though it was found.
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.

Available platform plugins are: eglfs, linuxfb, minimal, minimalegl, offscreen, vnc, wayland-egl, wayland, wayland-xcomposite-egl, wayland-xcomposite-glx, webgl, xcb.

[1] 17841 abort (core dumped) python show_points.py

好象是与Pyqt5有关,可视化代码为:

import mayavi.mlab
import torch
import numpy as np

mypointcloud=np.fromfile("/media/eric/My Passport/kitti/training/velodyne/003673.bin",dtype=np.float32,count=-1).reshape([-1,4])
mypointcloud=torch.from_numpy(mypointcloud)
print(mypointcloud.size())
print(mypointcloud.type())

def viz_mayavi(points,vals="distance"):
x=points[:,0]
y=points[:,1]
z=points[:,2]
r=points[:,3]
d=torch.sqrt(x**2+y**2)

if vals=="height":
col=z
else:
col=d

fig=mayavi.mlab.figure(bgcolor=(0,0,0),size=(1280,720))
mayavi.mlab.points3d(x,y,z,
col,
mode="point",
colormap='spectral',
figure=fig,
)

mayavi.mlab.show()

if __name__=="__main__":
viz_mayavi(mypointcloud,vals="height")

 

解决方法

export QT_DEBUG_PLUGINS=1
sudo apt install --reinstall libxcb-xinerama0

重新运行python程序就行了

参考文献

[1].Install fails with ubuntu repository. ​​https://github.com/i3/i3/issues/3252​

[2].Ubuntu18.04下Qt出现qt.qpa.plugin:Could not load the Qt platform plugin “xcb“错误怎么办. ​​https://m.yisu.com/zixun/310371.html​