File size: 697 Bytes
0aba763 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
def expand_bbox(bbox,left=5,top=5,right=5,bottom=5):
left_pixel = bbox[2]*(float(left)/100)
top_pixel = bbox[3]*(float(top)/100)
right_pixel = bbox[2]*(float(right)/100)
bottom_pixel = bbox[3]*(float(bottom)/100)
new_box = list(bbox)
new_box[0] -=left_pixel
new_box[1] -=top_pixel
new_box[2] +=left_pixel+right_pixel
new_box[3] +=top_pixel+bottom_pixel
return new_box
def to_int_bbox(bbox):
int_box = [
int(bbox[0]),
int(bbox[1]),
int(bbox[2]),
int(bbox[3])
]
return int_box
# for dlib rectangle
def to_right_bottom_bbox(bbox):
int_box = [
bbox[0],
bbox[1],
bbox[2]+bbox[0],
bbox[3]+bbox[1]
]
return int_box |