-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexperiments.py
60 lines (48 loc) · 1.7 KB
/
experiments.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
53
54
55
56
57
58
59
60
import argparse
import numpy as np
from points_removal_scripts.mesh_based_script import HPR_mesh_based
from points_removal_scripts.open3d_based_script import HPR_open3d
def get_visible_points_from_file(path):
marked_visibility = []
with open(path, "r") as data:
while True:
point = data.readline()
if not point:
break
marked_visibility.append(float(point.split()[5]))
return marked_visibility
def count_accuracy(cloud_size, estimated_visibility, marked_visibility):
coincide = 0
for i in range(cloud_size):
if marked_visibility[i] == estimated_visibility[i]:
coincide += 1
if cloud_size != 0:
return coincide / cloud_size
else:
raise ArithmeticError("invalid point cloud data")
# Calculate open3d method
parser = argparse.ArgumentParser(
description="""
This script takes path to the cloud data
"""
)
parser.add_argument("cloud_path", help="path to cloud data")
args = parser.parse_args()
cloud_path = args.cloud_path
pcd, pt_map = HPR_open3d.hidden_points_removal(cloud_path)
marked_visibility = get_visible_points_from_file(cloud_path)
cloud_size = len(marked_visibility)
estimated_visibility = np.zeros(cloud_size)
visible_indexes = np.asarray(pt_map)
estimated_visibility[visible_indexes] = 1
print(
"an accuracy score is: ",
count_accuracy(cloud_size, estimated_visibility, marked_visibility),
)
# Calculate mesh-based method
pcd, estimated_visibility = HPR_mesh_based.hidden_points_removal(cloud_path)
marked_visibility = get_visible_points_from_file(cloud_path)
print(
"an accuracy score is: ",
count_accuracy(cloud_size, estimated_visibility, marked_visibility),
)