This repository has been archived by the owner on Jun 27, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.py
49 lines (41 loc) · 1.57 KB
/
main.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
from functions import Dimensioning, Convert
import time
from subprocess import run
import open3d as o3d
import os.path
# store starting time
start = time.time()
userId = "3"
front_image = "TestBench/"+userId+"/front.jpg"
side_image = "TestBench/"+userId+"/side.jpg"
top_image = "TestBench/"+userId+"/top.jpg"
d1 = Dimensioning(userId, "front", front_image)
d2 = Dimensioning(userId, "side", side_image)
d3 = Dimensioning(userId, "top", top_image)
if(d1 == None or d2 == None or d3 == None):
exit(0)
# front view length of highlighted line
fratio = float(d1["ratio"]) * 2
# side view length of highlighted line
sratio = float(d2["ratio"]) * 2
# top view length of highlighted line
tratio = float(d3["ratio"]) * 2
print(Convert(userId, front_image, side_image, top_image, fratio, sratio, tratio))
# store end time
end = time.time()
print("Total time taken to convert:", end-start)
# store starting time
start = time.time()
scad_filename = "static/" + userId + '/' + userId + ".scad"
stl_filename = "static/" + userId + '/' + userId + ".stl"
pcd_filename = "static/" + userId + '/' + userId + ".pcd"
if(os.path.isfile(scad_filename)):
run("openscad -o " + stl_filename + " " + scad_filename)
if(os.path.isfile(stl_filename)):
mesh = o3d.io.read_triangle_mesh(stl_filename)
pointcloud = mesh.sample_points_poisson_disk(100000)
o3d.io.write_point_cloud(pcd_filename, pointcloud)
o3d.visualization.draw_geometries([pointcloud])
# store end time
end = time.time()
print("Total time taken to convert from stl to point cloud:", end-start)