-
Notifications
You must be signed in to change notification settings - Fork 0
/
Statistics.py
71 lines (55 loc) · 1.72 KB
/
Statistics.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
61
62
63
64
65
66
67
68
69
70
71
import json
class Statistics:
STAT = "statistics.json"
def __init__(self, total_images):
self.total_images = total_images
self.gcp_found = 0 # number of arUco markers found
self.img_with_gcp = 0 # number of images that probably contains a GCP
self.init()
def save_statistic(self, n, stage):
f = open(Statistics.STAT, "r")
data = json.load(f)
f.close()
if stage == "meta":
data["Processed"] += n
data["Total"] = self.total_images
elif stage == "contains_gcp":
self.img_with_gcp += n
data["Contains_GCP"] += n
elif stage == "aruco":
data["Processed_aruco"] += n
elif stage == "gcp_found":
self.gcp_found += n
data["GCP_found"] = self.gcp_found
f = open(Statistics.STAT, "w")
json.dump(data, f)
f.close()
@staticmethod
def init():
f = open(Statistics.STAT, "r")
data = json.load(f)
f.close()
data["Processed"] = 0
data["Total"] = 0
data["Contains_GCP"] = 0
data["Processed_aruco"] = 0
data["Total_aruco"] = 0
data["GCP_found"] = 0
f = open(Statistics.STAT, "w")
json.dump(data, f)
f.close()
@staticmethod
def update_aruco(value):
f = open(Statistics.STAT, "r")
data = json.load(f)
f.close()
data["Total_aruco"] = value
f = open(Statistics.STAT, "w")
json.dump(data, f)
f.close()
def get_total_images(self):
return self.total_images
def get_gcp_found(self):
return self.gcp_found
def get_img_with_gcp(self):
return self.img_with_gcp