From 394a162d76afd241b91b4c58be859c767607b4e5 Mon Sep 17 00:00:00 2001 From: davidpagnon Date: Tue, 17 Sep 2024 10:25:19 +0200 Subject: [PATCH] synchronizes on person with highest mean confidence --- Pose2Sim/synchronization.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Pose2Sim/synchronization.py b/Pose2Sim/synchronization.py index 2701596..2fbdf22 100644 --- a/Pose2Sim/synchronization.py +++ b/Pose2Sim/synchronization.py @@ -82,7 +82,9 @@ def convert_json2pandas(json_files, likelihood_threshold=0.6): for j_p in json_files: with open(j_p) as j_f: try: - json_data = json.load(j_f)['people'][0]['pose_keypoints_2d'] + json_data = json.load(j_f)['people'] + max_confidence_person = max(json_data, key=lambda p: np.mean(p['pose_keypoints_2d'][2::3])) + json_data = max_confidence_person['pose_keypoints_2d'] # remove points with low confidence json_data = np.array([[json_data[3*i],json_data[3*i+1],json_data[3*i+2]] if json_data[3*i+2]>likelihood_threshold else [0.,0.,0.] for i in range(nb_coord)]).ravel().tolist() except: