According to the definition of the function reorder_pts, It is entirely possible that, to make sure the order of the four edge center points(tt, rr, bb, ll), using np.argmax/np.argmin will make two of their indexes(l_ind, r_ind, t_ind, b_ind) have same value. In other words, one points may be both the leftmost and the uppermost at the same time. So if carrying on these operation, you may get repetitive points.
I think if you draw some rectangle boxes with random orientation on one paper, you may find that there will always has two edge center points (x1, y1) & (x2, y2) that meet the condition: x1 <= x2 and y1 < y2. Thus we can determine the top point tt(x1, y1) and the bottom point bb(x2, y2), then the left point ll(x3, y3) and the right point rr(x4, y4) meet the condition: x3 < x4 and y3 >= y4.
According to the definition of the function reorder_pts, It is entirely possible that, to make sure the order of the four edge center points(tt, rr, bb, ll), using np.argmax/np.argmin will make two of their indexes(l_ind, r_ind, t_ind, b_ind) have same value. In other words, one points may be both the leftmost and the uppermost at the same time. So if carrying on these operation, you may get repetitive points. I think if you draw some rectangle boxes with random orientation on one paper, you may find that there will always has two edge center points (x1, y1) & (x2, y2) that meet the condition: x1 <= x2 and y1 < y2. Thus we can determine the top point tt(x1, y1) and the bottom point bb(x2, y2), then the left point ll(x3, y3) and the right point rr(x4, y4) meet the condition: x3 < x4 and y3 >= y4.