-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathraycloudtools_evaluation.py
More file actions
46 lines (35 loc) · 1.74 KB
/
Copy pathraycloudtools_evaluation.py
File metadata and controls
46 lines (35 loc) · 1.74 KB
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
import os
import glob
import re
import open3d as o3d
from fire import Fire
from base_evaluation import BaseEvaluation
class RayCloudToolsEvaluation(BaseEvaluation):
def __init__(self, data_base_dir= "/Stor1/wout/BenchmarkPaper/data/", dataset="WYTHAM", use_cached_calculations=True, cache_calculations=True, debug=False):
self.method = "raycloudtools"
super(RayCloudToolsEvaluation, self).__init__(data_base_dir, dataset, use_cached_calculations, cache_calculations, debug)
return
def read_output(self):
'''
Read output RayCloudTools
Output format RayCloudTools: single ply with colored instances, color (0,0,0) is ground
Output format:
[tree1, tree2, ...] where treen is an o3d instance of tree
'''
# use cached predictions if enabled and present
self.prediction_cache_dir = os.path.join(self.calculation_cache_dir, "predictions", self.dataset, self.method)
if self.use_cached_calculations:
if not os.path.exists(self.prediction_cache_dir):
print(f"INFO: use_cached_calculations is true but predictions are not cached, rereading predictions")
else:
return self.read_cached_predictions()
# if not cached, read in predictions
FILENAME = self.dataset.lower() + "_test_raycloud_segmented.ply"
input_file = os.path.join(self.output_dir, FILENAME)
input_pc = o3d.t.io.read_point_cloud(input_file)
predictions = self.seperate_colored_instances(input_pc, remove_zero=True)
if self.cache_calculations:
self.cache_predictions(predictions)
return predictions
if __name__ == "__main__":
Fire(RayCloudToolsEvaluation)