#!/usr/bin/env bash
PYTHON=${PYTHON:-"python"}
#cuda 10.1
$PYTHON -mpip install ./torch-1.6.0+cu101-cp37-cp37m-linux_x86_64.whl
$PYTHON -mpip install ./torchvision-0.7.0+cu101-cp37-cp37m-linux_x86_64.whl
$PYTHON -mpip install ./torch_cluster-1.5.8+cu101-cp37-cp37m-linux_x86_64.whl
$PYTHON -mpip install ./torch_scatter-2.0.5+cu101-cp37-cp37m-linux_x86_64.whl
$PYTHON -mpip install ./torch_sparse-0.6.8+cu101-cp37-cp37m-linux_x86_64.whl
$PYTHON -mpip install ./torch_spline_conv-1.2.0+cu101-cp37-cp37m-linux_x86_64.whl
$PYTHON -mpip install torch_geometric==1.7.0 -i https://pypi.tuna.tsinghua.edu.cn/simple
$PYTHON -mpip install torch_points3d==1.2.0 -i https://pypi.tuna.tsinghua.edu.cn/simple
参考:
http://ziyedy.top/page/plyfile.html
https://www.pythonf.cn/read/69331
https://blog.csdn.net/weixin_44389243/article/details/106746240
https://blog.csdn.net/guaiderzhu1314/article/details/105749413/
输出的ply无法在cloudcompare上打开
我切换成pcd进行打开
# python3.8
# -*- coding: utf-8 -*-
# ---
# @Software: PyCharm
# @File: vis_ply.py
# @Author: ---
# @Institution: BeiJing, China
# @E-mail: lgdyangninghua@163.com
# @Site:
# @Time: 4月 26, 2021
# ---
import os
import numpy as np
import open3d as o3d
from plyfile import PlyData, PlyElement
HEADER = '''\
# .PCD v0.7 - Point Cloud Data file format
VERSION 0.7
FIELDS x y z label object
SIZE 4 4 4 4 4
TYPE F F F I I
COUNT 1 1 1 1 1
WIDTH {}
HEIGHT 1
VIEWPOINT 0 0 0 1 0 0 0
POINTS {}
DATA ascii
'''
def write_pcd(points, save_pcd_path):
n = len(points)
lines = []
for i in range(n):
x, y, z, label, object = points[i]
lines.append('{:.6f} {:.6f} {:.6f} {} {}'.format(x, y, z, label, object))
with open(save_pcd_path, 'w') as f:
f.write(HEADER.format(n, n))
f.write('\n'.join(lines))
def write_pcd(points, save_pcd_path):
with open(save_pcd_path, 'w') as f:
f.write(HEADER.format(len(points), len(points)) + '\n')
np.savetxt(f, points, delimiter=' ', fmt='%f %f %f %d %d')
def read_ply(filename):
""" 读取坐标,返回值为 n * 3 """
plydata = PlyData.read(filename)
x = plydata.elements[0].data['x']
y = plydata.elements[0].data['y']
z = plydata.elements[0].data['z']
p = plydata.elements[0].data['p'] #pred
l = plydata.elements[0].data['l'] #label
point = np.array([[_x, _y, _z, _p, _l] for _x, _y, _z, _p, _l in zip(x, y, z, p, l)])
return point
path = "torch-points3d-master/outputs/benchmark/benchmark-pointnet2_charlesssg-20210426_160121/viz/99/train/"
lines = os.listdir(path)
for m_ind, m_val in enumerate(lines):
if m_val.endswith('ply'):
point = read_ply(os.path.join(path, m_val))
xyzpred = point[:, :4]
h,w = xyzpred.shape
object = np.ones((h,1), dtype=np.int8)*(-1)
save_pcd_point = np.hstack((xyzpred, object))
write_pcd(save_pcd_point, os.path.join(path, m_val).replace('ply', 'pcd'))