Skip to content

Commit

Permalink
[Enhancement] update stitch_boxes_into_lines (#1824)
Browse files Browse the repository at this point in the history
  • Loading branch information
cherryjm authored Apr 3, 2023
1 parent 1c91a98 commit 4842599
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions mmocr/utils/bbox_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,14 +178,15 @@ def stitch_boxes_into_lines(boxes, max_x_dist=10, min_y_overlap_ratio=0.8):
lines = []
line_idx = 0
lines.append([line[0]])
rightmost = np.max(x_sorted_boxes[line[0]]['box'][::2])
for k in range(1, len(line)):
curr_box = x_sorted_boxes[line[k]]
prev_box = x_sorted_boxes[line[k - 1]]
dist = np.min(curr_box['box'][::2]) - np.max(prev_box['box'][::2])
dist = np.min(curr_box['box'][::2]) - rightmost
if dist > max_x_dist:
line_idx += 1
lines.append([])
lines[line_idx].append(line[k])
rightmost = max(rightmost, np.max(curr_box['box'][::2]))

# Get merged boxes
for box_group in lines:
Expand Down

0 comments on commit 4842599

Please sign in to comment.