代码链接,该代码中pypcd依赖python2,python3中不好用
GitHub - Zhou-Renjie/pcd2bin: .pcd to .bin converter (python)
$ pip install numpy
$ pip install argparse
$ pip install pypcd
$ pip install tqdm
安装pypcd时报错:
1.
building 'lzf' extension
error: Microsoft Visual C++ 9.0 is required. Get it from http://aka.ms/vcpython27
双击安装VCForPython27.msi即可
2.
error: command ‘C:\Users\***\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\VC\Bin\amd64\cl.exe’ failed with exit status 2
把stdin.h复制到下面的路径下即可
C:\Users\***\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\VC\include
3.
使用pypcd时出现ValueError: field '__0000' occurs more than once
打开pypcd安装位置的pypcd.py,安装位置可以在报错界面查看:
C:\Users\***\.conda\envs\py27\Lib\site-packages\pypcd\pypcd.py
找到77行左右
def parse_header(lines):
""" Parse header of PCD files.
"""
metadata = {}
for ln in lines:
if ln.startswith('#') or len(ln) < 2:
continue
match = re.match('(\w+)\s+([\w\s\.]+)', ln)
改为
def parse_header(lines):
"""
Parse header of PCD files.
"""
metadata = {}
for ln in lines:
if ln.startswith('#') or len(ln) < 2:
continue
ln = ln.replace('_','s',1)
ln = ln.replace('_','m',1)
match = re.match('(\w+)\s+([\w\s.]+)', str(ln))
其他的pypcd问题在下面网站找到:
Issues · dimatura/pypcd (github.com)
运行程序:
python pcd2bin.py --pcd_path={path of input pcd file directory} --bin_path={path of output bin file directory}
或者在程序中直接填写你的文件路径