@@ -1515,7 +1515,6 @@ def process_fun(config_dict, video_file, time_range, frame_rate, result_dir):
15151515 cv2 .namedWindow (f'{ video_file } Sports2D' , cv2 .WINDOW_NORMAL + cv2 .WINDOW_KEEPRATIO )
15161516 cv2 .setWindowProperty (f'{ video_file } Sports2D' , cv2 .WND_PROP_ASPECT_RATIO , cv2 .WINDOW_FULLSCREEN )
15171517
1518-
15191518 # Select the appropriate model based on the model_type
15201519 logging .info ('\n Estimating pose...' )
15211520 pose_model_name = pose_model
@@ -2035,8 +2034,11 @@ def process_fun(config_dict, video_file, time_range, frame_rate, result_dir):
20352034 for i in range (all_frames_angles_homog .shape [1 ]): # for each person
20362035 for j in range (all_frames_angles_homog .shape [2 ]): # for each angle
20372036 valid_mask = ~ np .isnan (all_frames_angles_homog [:, i , j ])
2038- all_frames_angles_homog [valid_mask , i , j ] = np .unwrap (all_frames_angles_homog [valid_mask , i , j ], period = 180 )
2039-
2037+ ang = np .unwrap (all_frames_angles_homog [valid_mask , i , j ], period = 180 )
2038+ ang = ang - 360 if ang .mean ()> 180 else ang
2039+ ang = ang + 360 if ang .mean ()< - 180 else ang
2040+ all_frames_angles_homog [valid_mask , i , j ] = ang
2041+
20402042 # Process angles for each person
20412043 for i , idx_person in enumerate (selected_persons ):
20422044 angles_path_person = angles_output_path .parent / (angles_output_path .stem + f'_person{ i :02d} .mot' )
0 commit comments