Update eynollah.py

reading order bug for documents with text regions less than 5: fixed
pull/28/head
vahidrezanezhad 4 years ago committed by GitHub
parent 1ee219b657
commit 73b7c780ab
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1672,10 +1672,17 @@ class Eynollah:
cx_bigest_d_big, cy_biggest_d_big, _, _, _, _, _ = find_new_features_of_contours([contours_biggest_d]) cx_bigest_d_big, cy_biggest_d_big, _, _, _, _, _ = find_new_features_of_contours([contours_biggest_d])
cx_bigest_d, cy_biggest_d, _, _, _, _, _ = find_new_features_of_contours(contours_only_text_parent_d) cx_bigest_d, cy_biggest_d, _, _, _, _, _ = find_new_features_of_contours(contours_only_text_parent_d)
try: try:
cx_bigest_d_last5 = cx_bigest_d[-5:] if len(cx_bigest_d) >= 5:
cy_biggest_d_last5 = cy_biggest_d[-5:] cx_bigest_d_last5 = cx_bigest_d[-5:]
dists_d = [math.sqrt((cx_bigest_big[0] - cx_bigest_d_last5[j]) ** 2 + (cy_biggest_big[0] - cy_biggest_d_last5[j]) ** 2) for j in range(len(cy_biggest_d_last5))] cy_biggest_d_last5 = cy_biggest_d[-5:]
ind_largest = len(cx_bigest_d) -5 + np.argmin(dists_d) dists_d = [math.sqrt((cx_bigest_big[0] - cx_bigest_d_last5[j]) ** 2 + (cy_biggest_big[0] - cy_biggest_d_last5[j]) ** 2) for j in range(len(cy_biggest_d_last5))]
ind_largest = len(cx_bigest_d) -5 + np.argmin(dists_d)
else:
cx_bigest_d_last5 = cx_bigest_d[-len(cx_bigest_d):]
cy_biggest_d_last5 = cy_biggest_d[-len(cx_bigest_d):]
dists_d = [math.sqrt((cx_bigest_big[0]-cx_bigest_d_last5[j])**2 + (cy_biggest_big[0]-cy_biggest_d_last5[j])**2) for j in range(len(cy_biggest_d_last5))]
ind_largest = len(cx_bigest_d) - len(cx_bigest_d) + np.argmin(dists_d)
cx_bigest_d_big[0] = cx_bigest_d[ind_largest] cx_bigest_d_big[0] = cx_bigest_d[ind_largest]
cy_biggest_d_big[0] = cy_biggest_d[ind_largest] cy_biggest_d_big[0] = cy_biggest_d[ind_largest]
except Exception as why: except Exception as why:

Loading…
Cancel
Save