-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathSavePLY.py
31 lines (28 loc) · 836 Bytes
/
SavePLY.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
'''This code is a part of the 3D Scanner project'''
'''Developed by team SAAS'''
'''Ekalavya 2017'''
'''IIT Bombay'''
def SavePLY(X,Y,Z): #function for saving the .ply file
f=open("object.ply","w+") #a file is opened for writing
s=[]
for i in range(9):
s.append("0")
#the header of the ply file is defined
s[0]="ply"
s[1]="format ascii 1.0"
s[2]="element vertex "+ str(len(X))
s[3]="property float32 x"
s[4]="property float32 y"
s[5]="property float32 z"
s[6]="element face 0"
s[7]="property list uint8 int32 vertex_indices"
s[8]="end_header"
#the header for "object.ply" is written
for i in range(len(s)):
f.write(s[i]+"\n")
#Creating a .ply file from the coordinates in the list X,Y,Z respectively
for i in range(len(X)):
f.write(str(X[i])+" ")
f.write(str(Y[i])+" ")
f.write(str(Z[i])+"\n")
f.close()