-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathArrayToSTL_TEST1.py
78 lines (32 loc) · 1.26 KB
/
ArrayToSTL_TEST1.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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
########################################################################
# ArrayToSTL #
########################################################################
# This script is designed to take a given array (allPoints) and
# convert it to an STL file
import cv2 as cv
import numpy as np
from matplotlib import pyplot as plt
import os
from mpl_toolkits.mplot3d import Axes3D
from scipy.spatial import ConvexHull
# Import the array-creation functions
from ImagesToArray import *
if __name__ == '__main__':
# For testing purposes
pathToImages = DIRECTORY + 'TestPhotos/'
print ('Extracting points from images...')
filteredPoints = getPoints(pathToImages)
#print np.array(filteredPoints)
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
points= np.array(filteredPoints)
hull = ConvexHull(points)
edges = list(zip(*points))
# Simplices define the 3 points making up a triangle
for simplex in hull.simplices:
plt.plot(points[simplex,0], points[simplex,1], points[simplex,2], 'r-')
ax.plot(edges[0],edges[1],edges[2],'bo')
ax.set_xlabel('x')
ax.set_ylabel('y')
ax.set_zlabel('z')
plt.show()