forked from gilbeckers/MultiPersonMatching
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathunvalid_input.py
77 lines (59 loc) · 2.45 KB
/
unvalid_input.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
import pose_match
import parse_openpose_json
import numpy as np
import logging
import prepocessing
import matplotlib.pyplot as plt
'''
-------------------------------- UNVALID POSES TEST CASE -------------------------------------------
Testjes voor unvalid input poses (single person)
'''
logging.basicConfig(level=logging.DEBUG)
logger = logging.getLogger("pose_match")
json_data_path = 'data/json_data/'
images_data_path = 'data/image_data/'
model = "1027"
input = "846"
model_json = json_data_path + model + '.json'
input_json = json_data_path + input + '.json'
model_image = images_data_path + model + '.png'
input_image = images_data_path + input + '.png'
model_features = parse_openpose_json.parse_JSON_single_person(model_json)
input_features = parse_openpose_json.parse_JSON_single_person(input_json)
# Some testcases ...
'''
unvalid_list = [
[[3], "LShoulder" ],
[[6], "RShoulder"],
[[3,6], "L&R Shoulder"],
[[2, 3, 6], "LElbow + L&R Shoulder"],
[[2, 3, 6, 7], "LElbow + L&R Shoulder + RWrist"],
[[2, 3, 6, 7, 4], "LElbow + L&R Shoulder + L&RWrist"],
]
'''
unvalid_list = [
[[9], "RKnee" ],
[[8], "RHip" ],
[[9, 12], "L&R Knee" ],
[[9, 12, 13 ], "L&R Knee + LAnkle"],
]
# With valid input and valid model
match_result = pose_match.single_person(model_features, input_features, True)
logger.info("--Match or not: %s ", str(match_result.match_bool))
pose_match.plot_single_person(model_features, input_features, model_image, input_image,
"valid input", "valid model",
"match result: " + str(match_result.match_bool) + "(" + str(round(match_result.error_score, 5)) + ")")
'''
Make the inputpose unvalid by altering some features to (0,0)
'''
for unvalid_test_item in unvalid_list:
input_features_unvalid = np.copy(input_features)
for unvalid_feature in unvalid_test_item[0]:
# input_features_unvalid[3] = np.array([0,0])
input_features_unvalid[unvalid_feature] = np.array([0, 0])
match_result = pose_match.single_person(model_features, input_features_unvalid, True)
logger.info("--Match or not: %s ", str(match_result.match_bool))
pose_match.plot_single_person(model_features, input_features_unvalid, model_image, input_image,
unvalid_test_item[1], "valid model",
"match result: " + str(match_result.match_bool) + "(" + str(round(match_result.error_score, 5)) + ")")
plt.show()