Skip to content

Commit 4a06ee3

Browse files
authored
add 5% margin in bboxes
1 parent cde7eaa commit 4a06ee3

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

Pose2Sim/Utilities/reproj_from_trc_calib.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,7 @@ def dataset_to_mmpose2d(coords_df, mmpose_json_file, img_size, markerset='custom
297297
labels2d_json_data['images'] = []
298298
labels2d_json_data['annotations'] = []
299299
labels2d_json_data['categories'] = [{'id': 1, 'name': 'person'}]
300+
padding = 0.05
300301

301302
# for each image
302303
persons = list(set(['_'.join(item.split('_')[:5]) for item in coords_df.columns.levels[1]]))
@@ -332,7 +333,11 @@ def dataset_to_mmpose2d(coords_df, mmpose_json_file, img_size, markerset='custom
332333
bbox_height = np.round(max_y - min_y, decimals=1)
333334
# bbox = [min_x, min_y, max_x, max_y]
334335
bbox = [min_x, min_y, bbox_width, bbox_height] # coco format
335-
# bbox = [min_x-bbox_width*0.1, min_y-bbox_height*0.1, bbox_width*1.2, bbox_height]*1.2 # + 10 % margin
336+
# add padding
337+
bbox = [min(0, min_x-bbox_width*padding),
338+
min(0, min_y-bbox_height*padding),
339+
bbox_width*(1+padding*2) if max_x+bbox_width*padding < w else bbox_width*(1+padding),
340+
bbox_height*(1+padding*2) if max_y+bbox_height*padding < h else bbox_height*(1+padding)]
336341

337342
ann_id = str_to_id(person+file_name)
338343
category_id = 1

0 commit comments

Comments
 (0)