Created
March 12, 2017 15:50
-
-
Save papachristoumarios/332cb0d8674c670eccf0f59a2fbd24b9 to your computer and use it in GitHub Desktop.
A simple PLY pointcloud plotter in Python with matplotilib and numpy
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from mpl_toolkits.mplot3d import Axes3D | |
import matplotlib.pyplot as plt | |
import numpy as np | |
def get_pts(infile): | |
data = np.loadtxt(infile, delimiter=',') | |
return data[12:,0], data[12:,1], data[12:,2] #returns X,Y,Z points skipping the first 12 lines | |
def plot_ply(infile): | |
fig = plt.figure() | |
ax = fig.add_subplot(111, projection='3d') | |
x,y,z = get_pts(infile) | |
ax.scatter(x, y, z, c='r', marker='o') | |
ax.set_xlabel('X Label') | |
ax.set_ylabel('Y Label') | |
ax.set_zlabel('Z Label') | |
plt.show() | |
if __name__ == '__main__': | |
infile = 'pointcloud.ply' | |
plot_ply(infile) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment