|
|
|
@ -387,7 +387,8 @@ def separate_lines(img_patch, contour_text_interest, thetha, x_help, y_help):
|
|
|
|
|
if point_down_narrow >= img_patch.shape[0]:
|
|
|
|
|
point_down_narrow = img_patch.shape[0] - 2
|
|
|
|
|
|
|
|
|
|
distances = [cv2.pointPolygonTest(contour_text_interest_copy, (xv[mj], peaks[jj] + first_nonzero), True)
|
|
|
|
|
|
|
|
|
|
distances = [cv2.pointPolygonTest(contour_text_interest_copy, tuple(int(x) for x in np.array([xv[mj], peaks[jj] + first_nonzero])), True)
|
|
|
|
|
for mj in range(len(xv))]
|
|
|
|
|
distances = np.array(distances)
|
|
|
|
|
|
|
|
|
@ -448,8 +449,7 @@ def separate_lines(img_patch, contour_text_interest, thetha, x_help, y_help):
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
elif len(peaks) == 1:
|
|
|
|
|
|
|
|
|
|
distances = [cv2.pointPolygonTest(contour_text_interest_copy, (xv[mj], peaks[0] + first_nonzero), True)
|
|
|
|
|
distances = [cv2.pointPolygonTest(contour_text_interest_copy, tuple(int(x) for x in np.array([xv[mj], peaks[0] + first_nonzero])), True)
|
|
|
|
|
for mj in range(len(xv))]
|
|
|
|
|
distances = np.array(distances)
|
|
|
|
|
|
|
|
|
@ -530,7 +530,7 @@ def separate_lines(img_patch, contour_text_interest, thetha, x_help, y_help):
|
|
|
|
|
except:
|
|
|
|
|
point_up =peaks[jj] + first_nonzero - int(1. / 1.8 * dis_to_next)
|
|
|
|
|
|
|
|
|
|
distances = [cv2.pointPolygonTest(contour_text_interest_copy, (xv[mj], peaks[jj] + first_nonzero), True)
|
|
|
|
|
distances = [cv2.pointPolygonTest(contour_text_interest_copy, tuple(int(x) for x in np.array([xv[mj], peaks[jj] + first_nonzero])), True)
|
|
|
|
|
for mj in range(len(xv))]
|
|
|
|
|
distances = np.array(distances)
|
|
|
|
|
|
|
|
|
@ -612,7 +612,7 @@ def separate_lines(img_patch, contour_text_interest, thetha, x_help, y_help):
|
|
|
|
|
point_up = peaks[jj] + first_nonzero - int(1. / 1.9 * dis_to_next_up)
|
|
|
|
|
point_down = peaks[jj] + first_nonzero + int(1. / 1.9 * dis_to_next_down)
|
|
|
|
|
|
|
|
|
|
distances = [cv2.pointPolygonTest(contour_text_interest_copy, (xv[mj], peaks[jj] + first_nonzero), True)
|
|
|
|
|
distances = [cv2.pointPolygonTest(contour_text_interest_copy, tuple(int(x) for x in np.array([xv[mj], peaks[jj] + first_nonzero])), True)
|
|
|
|
|
for mj in range(len(xv))]
|
|
|
|
|
distances = np.array(distances)
|
|
|
|
|
|
|
|
|
@ -789,7 +789,7 @@ def separate_lines_vertical(img_patch, contour_text_interest, thetha):
|
|
|
|
|
if point_down_narrow >= img_patch.shape[0]:
|
|
|
|
|
point_down_narrow = img_patch.shape[0] - 2
|
|
|
|
|
|
|
|
|
|
distances = [cv2.pointPolygonTest(contour_text_interest_copy, (xv[mj], peaks[jj] + first_nonzero), True) for mj in range(len(xv))]
|
|
|
|
|
distances = [cv2.pointPolygonTest(contour_text_interest_copy, tuple(int(x) for x in np.array([xv[mj], peaks[jj] + first_nonzero])), True) for mj in range(len(xv))]
|
|
|
|
|
distances = np.array(distances)
|
|
|
|
|
|
|
|
|
|
xvinside = xv[distances >= 0]
|
|
|
|
@ -871,7 +871,7 @@ def separate_lines_vertical(img_patch, contour_text_interest, thetha):
|
|
|
|
|
point_down = img_patch.shape[0] - 2
|
|
|
|
|
point_up = peaks[jj] + first_nonzero - int(1.0 / 1.8 * dis_to_next)
|
|
|
|
|
|
|
|
|
|
distances = [cv2.pointPolygonTest(contour_text_interest_copy, (xv[mj], peaks[jj] + first_nonzero), True) for mj in range(len(xv))]
|
|
|
|
|
distances = [cv2.pointPolygonTest(contour_text_interest_copy, tuple(int(x) for x in np.array([xv[mj], peaks[jj] + first_nonzero])), True) for mj in range(len(xv))]
|
|
|
|
|
distances = np.array(distances)
|
|
|
|
|
|
|
|
|
|
xvinside = xv[distances >= 0]
|
|
|
|
@ -931,7 +931,7 @@ def separate_lines_vertical(img_patch, contour_text_interest, thetha):
|
|
|
|
|
point_up = peaks[jj] + first_nonzero - int(1.0 / 1.9 * dis_to_next_up)
|
|
|
|
|
point_down = peaks[jj] + first_nonzero + int(1.0 / 1.9 * dis_to_next_down)
|
|
|
|
|
|
|
|
|
|
distances = [cv2.pointPolygonTest(contour_text_interest_copy, (xv[mj], peaks[jj] + first_nonzero), True) for mj in range(len(xv))]
|
|
|
|
|
distances = [cv2.pointPolygonTest(contour_text_interest_copy, tuple(int(x) for x in np.array([xv[mj], peaks[jj] + first_nonzero])), True) for mj in range(len(xv))]
|
|
|
|
|
distances = np.array(distances)
|
|
|
|
|
|
|
|
|
|
xvinside = xv[distances >= 0]
|
|
|
|
@ -1382,7 +1382,7 @@ def textline_contours_postprocessing(textline_mask, slope, contour_text_interest
|
|
|
|
|
# textline_mask = cv2.erode(textline_mask, kernel, iterations=1)
|
|
|
|
|
|
|
|
|
|
# print(textline_mask.shape[0]/float(textline_mask.shape[1]),'miz')
|
|
|
|
|
try:
|
|
|
|
|
#try:
|
|
|
|
|
# if np.abs(slope)>.5 and textline_mask.shape[0]/float(textline_mask.shape[1])>3:
|
|
|
|
|
# plt.imshow(textline_mask)
|
|
|
|
|
# plt.show()
|
|
|
|
@ -1455,9 +1455,9 @@ def textline_contours_postprocessing(textline_mask, slope, contour_text_interest
|
|
|
|
|
else:
|
|
|
|
|
_, contours_rotated_clean = separate_lines(dst, contours_text_rot[ind_big_con], slope, x_help, y_help)
|
|
|
|
|
|
|
|
|
|
except:
|
|
|
|
|
#except:
|
|
|
|
|
|
|
|
|
|
contours_rotated_clean = []
|
|
|
|
|
#contours_rotated_clean = []
|
|
|
|
|
|
|
|
|
|
return contours_rotated_clean
|
|
|
|
|
|
|
|
|
|