@@ -286,7 +286,6 @@ def json_to_csv(json_path, frame_rate, pose_model, interp_gap_smaller_than, filt
286
286
model = eval (pose_model )
287
287
keypoints_ids = [node .id for _ , _ , node in RenderTree (model ) if node .id != None ]
288
288
keypoints_names = [node .name for _ , _ , node in RenderTree (model ) if node .id != None ]
289
- keypoints_names_rearranged = [y for x ,y in sorted (zip (keypoints_ids ,keypoints_names ))]
290
289
keypoints_nb = len (keypoints_ids )
291
290
292
291
# Retrieve coordinates
@@ -300,7 +299,8 @@ def json_to_csv(json_path, frame_rate, pose_model, interp_gap_smaller_than, filt
300
299
keypt = []
301
300
# Retrieve coords for this frame
302
301
for ppl in range (len (json_file ['people' ])): # for each detected person
303
- keypt += [np .asarray (json_file ['people' ][ppl ]['pose_keypoints_2d' ]).reshape (- 1 ,3 )]
302
+ keypt_all = np .asarray (json_file ['people' ][ppl ]['pose_keypoints_2d' ]).reshape (- 1 ,3 )[keypoints_ids ]
303
+ keypt += [keypt_all ]
304
304
keypt = np .array (keypt )
305
305
# Make sure keypt is as large as the number of persons that need to be detected
306
306
if len (keypt ) < nb_persons_to_detect :
@@ -321,7 +321,7 @@ def json_to_csv(json_path, frame_rate, pose_model, interp_gap_smaller_than, filt
321
321
# Prepare csv header
322
322
scorer = ['DavidPagnon' ]* (keypoints_nb * 3 + 1 )
323
323
individuals = [f'person{ i } ' ]* (keypoints_nb * 3 + 1 )
324
- bodyparts = [[p ]* 3 for p in keypoints_names_rearranged ]
324
+ bodyparts = [[p ]* 3 for p in keypoints_names ]
325
325
bodyparts = ['Time' ]+ [item for sublist in bodyparts for item in sublist ]
326
326
coords = ['seconds' ]+ ['x' , 'y' , 'likelihood' ]* keypoints_nb
327
327
tuples = list (zip (scorer , individuals , bodyparts , coords ))
@@ -604,7 +604,7 @@ def detect_pose_fun(config_dict, video_file):
604
604
605
605
if pose_algo == 'OPENPOSE' :
606
606
pose_model = config_dict .get ('pose' ).get ('OPENPOSE' ).get ('openpose_model' )
607
- json_path = result_dir / '_' .join ((video_file_stem ,pose_model , 'json' ))
607
+ json_path = result_dir / '_' .join ((video_file_stem ,'json' ))
608
608
609
609
# Pose detection skipped if load existing json files
610
610
if load_pose and len (list (json_path .glob ('*' )))> 0 :
@@ -633,8 +633,8 @@ def detect_pose_fun(config_dict, video_file):
633
633
elif platform == "linux" or platform == "linux2" :
634
634
run_openpose_linux (video_path , json_path , pose_model )
635
635
os .chdir (root_dir )
636
-
637
-
636
+
637
+
638
638
elif pose_algo == 'BLAZEPOSE' :
639
639
pose_model = pose_algo
640
640
json_path = result_dir / '_' .join ((video_file_stem ,pose_algo ,'json' ))
0 commit comments