def get_response_including_barcode(barcode_coords: BoundingBox, first_response_coords: BoundingBox, page_size: Size) -> BoundingBox: ret_bb = BoundingBox( Point(0, barcode_coords.top_left.y), Point(barcode_coords.bottom_right.x, barcode_coords.bottom_right.y + first_response_coords.height)) return ret_bb.add_padding(15, page_size)
def get_response_codes_bounding_box(response_codes: List[ResponseCode], page: Page) -> BoundingBox: x_min = 99999999 # TODO: switch out for INT_MAX x_max = 0 y_min = 99999999 y_max = 0 for response_code in response_codes: x_min = min(x_min, response_code.bounding_box.top_left.x) y_min = min(y_min, response_code.bounding_box.top_left.y) x_max = max(x_max, response_code.bounding_box.bottom_right.x) y_max = max(y_max, response_code.bounding_box.bottom_right.y) ret_bb = BoundingBox(Point(x_min, y_min), Point(x_max, y_max)) return ret_bb.add_padding(20, page.size)