forked from gilbeckers/MultiPersonMatching
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main_single_person.py
56 lines (42 loc) · 1.77 KB
/
main_single_person.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
import pose_match
import parse_openpose_json
import numpy as np
import logging
import prepocessing
import matplotlib.pyplot as plt
logging.basicConfig(level=logging.DEBUG)
logger = logging.getLogger("pose_match")
json_data_path = 'data/json_data/'
images_data_path = 'data/image_data/'
json_data_path = 'data/json_data/'
images_data_path = 'data/image_data/'
'''
-------------------------------- SINGLE PERSON -------------------------------------------
Read openpose output and parse body-joint points into an 2D arr ay of 18 rows
Elke entry is een coordinatenkoppel(joint-point) in 3D , z-coordinaat wordt nul gekozen want we werken in 2D
'''
model = "trap7"
input = "trap9"
model = "foto1"
input = "kleuter8"
model_json = json_data_path + model + '.json'
input_json = json_data_path + input + '_keypoints.json'
model_image = images_data_path + model + '.jpg'
input_image = images_data_path + input + '.jpg'
model_features = parse_openpose_json.parse_JSON_single_person(model_json)
input_features = parse_openpose_json.parse_JSON_single_person(input_json)
'''
Calculate match fo real (incl. normalizing)
'''
#TODO: edit return tuple !!
match_result = pose_match.single_person(model_features, input_features, True)
logger.info("--Match or not: %s score=%f ", str(match_result.match_bool), match_result.error_score)
'''
Calculate match + plot the whole thing
'''
# Reload features bc model_features is a immutable type -> niet meer nodig want er wordt een copy gemaalt in single_psoe()
# and is changed in single_pose in case of undetected bodyparts
model_features = parse_openpose_json.parse_JSON_single_person(model_json)
input_features = parse_openpose_json.parse_JSON_single_person(input_json)
pose_match.plot_single_person(model_features, input_features, model_image, input_image)
plt.show()