pycognaize.common.utils.stick_word_boxes
- stick_word_boxes(box_coord, img_bytes, padding=1)[source]
- Stick boxes with OpenCV
- Stick by y (height), add “2 pixel” padding in bottom and right
Get bigger sequence of 255 < vectors_y < 0 –> bigger_sequence new_top = min(bigger_sequence) new_bottom = max(bigger_sequence)
- stick by x (width), add “2 pixel” padding in bottom
Get numpy array of 255 < vectors_x < 0 –> min_max_x new_left = min(min_max_x) new_right = max(min_max_x)
- Parameters:
box_coord (
List
[dict
]) – List of dictionaries representing boxes with the following format: ({‘left’: <int>, ‘right’: <int>, ‘top’: <int>, ‘bottom’: <int>})img_bytes (
bytes
) – The original image to which the coordinates correspond topadding – Expand the final boxes with this amount of pixels on each four sides
- Returns: