|
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 |
|
|
|
|
|
def to_right_bottom_bbox(bbox): |
|
int_box = [ |
|
bbox[0], |
|
bbox[1], |
|
bbox[2]+bbox[0], |
|
bbox[3]+bbox[1] |
|
] |
|
return int_box |