-
Notifications
You must be signed in to change notification settings - Fork 1
/
test_dict.py
111 lines (96 loc) · 4.27 KB
/
test_dict.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
test_dict = {
"version": 1.2,
"mapping": {
"VideoStream": {
"args": {"webcam_id": 0},
"processors": [
{
"FaceLandmarkProcessor": {
"triggers": [
{
"RegionOfInterest": {
"args": {"position": [0, 0], "size": [0.3, 0.3], "landmarks": [1]},
"action": ["Logger"],
}
},
{
"LandmarkDistance": {
"args": {"landmarks": [12, 15], "threshold": 0.02},
"action": [{"MouseClick": {"args": {"key_name": "left_down"}}}],
}
},
{
"LandmarkDistance": {
"args": {"landmarks": [12, 15], "threshold": 0.02, "direction": "smaller"},
"action": [{"MouseClick": {"args": {"key_name": "left_up"}}}],
}
},
{
"LandmarkDistance": {
"args": {"landmarks": [61, 291], "threshold": 0.09, "direction": "smaller"},
"action": [{"MouseClick": {"args": {"key_name": "right"}}}],
}
},
],
"processors": [
{
"LandmarkEuroFilter": {
"args": {"min_cutoff": 1, "beta": 0},
"triggers": [
{
"RelativeCursorControl": {
"args": {
"x_threshold": 0.02,
"y_threshold": 0.03,
"velocity_compensation_x": 0.05,
"velocity_compensation_y": 0.5,
},
"action": ["MoveMouse"],
}
}
],
}
}
],
}
}
],
}
},
}
# my_dict = {"level1": {"level2": {"level3": "target_value"}}}
# my_dict["level1"]["level2"]["level3"] = "new_value"
# test_dict["mapping"]["VideoStream"]["processors"]["FaceLandmarkProcessor"],["triggers"] "LandmarkDistance", "args", "threshold"], value
def update_processingunit_dict(path, value):
# Updates the config dictionary based on a given path.
# e.g. update_config(['mapping', 'VideoStream', 'args', 'webcam_id'], 1)
from ctrlability.core.config_parser import ConfigParser
self.config = ConfigParser().get_config_as_dict()
temp_config = self.config
for key in path[:-1]: # Gehe zum vorletzten Schlüssel
temp_config = temp_config[key]
temp_config[path[-1]] = value # Setze den neuen Wert
print("//////////////////////////")
print(self.config)
def main():
print("*******************************")
print(test_dict)
print("*******************************")
print(
test_dict["mapping"]["VideoStream"]["processors"][0]["FaceLandmarkProcessor"]["triggers"][1][
"LandmarkDistance"
]["args"]["threshold"]
)
test_dict["mapping"]["VideoStream"]["processors"][0]["FaceLandmarkProcessor"]["triggers"][1]["LandmarkDistance"][
"args"
]["threshold"] = -999
print("*******************************")
print(test_dict)
print("*******************************")
# for k, v in test_dict.items():
# if isinstance(v, dict):
# print(v)
# else:
# print("{0} : {1}".format(k, v))
if __name__ == "__main__":
main()