Skip to content

Commit c289eb1

Browse files
committed
Fixed synchronization lag when GUI is false (largest bounding box between (value, nan) was nan because of use of argmax instead of argnanmax)
1 parent e2d821f commit c289eb1

2 files changed

Lines changed: 6 additions & 6 deletions

File tree

Pose2Sim/poseEstimation.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -557,13 +557,13 @@ def process_images(image_folder_path, vid_img_extension, pose_tracker, pose_mode
557557
def process_video_worker(video_path, ModelClass, det_frequency, mode, backend, device,
558558
pose_model, output_format, save_video, save_images,
559559
display_detection, frame_range, tracking_mode, multi_person,
560-
max_distance_px, deepsort_params, _init_lock):
560+
max_distance_px, deepsort_params, init_lock=None):
561561
'''
562562
Worker function for parallel pose estimation. Creates its own PoseTracker
563563
and optional DeepSort tracker, then processes one video independently.
564564
'''
565-
if _init_lock is not None:
566-
with _init_lock:
565+
if init_lock is not None:
566+
with init_lock:
567567
pose_tracker = setup_pose_tracker(ModelClass, det_frequency, mode, False, backend, device)
568568
else:
569569
pose_tracker = setup_pose_tracker(ModelClass, det_frequency, mode, False, backend, device)

Pose2Sim/synchronization.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1225,7 +1225,7 @@ def convert_json2pandas(json_files, likelihood_threshold=0.6, keypoints_ids=[],
12251225
for p in json_data_all
12261226
for keypoints in [np.array([p['pose_keypoints_2d'][3*i:3*i+3] for i in keypoints_ids])]
12271227
]
1228-
max_area_person = json_data_all[np.argmax(bbox_area)]
1228+
max_area_person = json_data_all[np.nanargmax(bbox_area)]
12291229
json_data = np.array([max_area_person['pose_keypoints_2d'][3*i:3*i+3] for i in keypoints_ids])
12301230

12311231
elif synchronization_gui:
@@ -1434,6 +1434,7 @@ def synchronize_cams_all(config_dict):
14341434
keypoints_names = [node.name for _, _, node in RenderTree(model) if node.id!=None]
14351435

14361436
# List json files
1437+
logging.info('Synchronizing...')
14371438
try:
14381439
pose_listdirs_names = next(os.walk(pose_dir))[1]
14391440
os.listdir(os.path.join(pose_dir, pose_listdirs_names[0]))[0]
@@ -1488,7 +1489,6 @@ def synchronize_cams_all(config_dict):
14881489

14891490

14901491
# Extract, interpolate, and filter keypoint coordinates
1491-
logging.info('Synchronizing...')
14921492
df_coords = []
14931493
b, a = signal.butter(int(filter_order/2), filter_cutoff/(fps/2), 'low', analog = False)
14941494
json_files_names_range = [[j for j in json_files_cam if int(re.split(r'(\d+)',j)[-2]) in range(*frames_cam)] for (json_files_cam, frames_cam) in zip(json_files_names,search_around_frames)]
@@ -1528,7 +1528,7 @@ def synchronize_cams_all(config_dict):
15281528
else:
15291529
selected_id_list = [None] * cam_nb
15301530
if isinstance(approx_time_maxspeed, list): # search around max speed
1531-
logging.info(f'Synchronization is calculated around the times {approx_time_maxspeed} +/- {time_range_around_maxspeed} s.')
1531+
logging.info(f'Synchronization is calculated at time {approx_time_maxspeed} ± {time_range_around_maxspeed} s.')
15321532
elif approx_time_maxspeed == 'auto': # search on the whole sequence (slower if long sequence)
15331533
logging.info('Synchronization is calculated on the whole sequence. This may take a while.')
15341534
else:

0 commit comments

Comments
 (0)