|
|
@ -41,7 +41,7 @@ def get_text_region_boxes_by_given_contours(contours):
|
|
|
|
del contours
|
|
|
|
del contours
|
|
|
|
return boxes, contours_new
|
|
|
|
return boxes, contours_new
|
|
|
|
|
|
|
|
|
|
|
|
def filter_contours_area_of_image(image, contours, hirarchy, max_area, min_area):
|
|
|
|
def filter_contours_area_of_image(image, contours, hierarchy, max_area, min_area):
|
|
|
|
found_polygons_early = list()
|
|
|
|
found_polygons_early = list()
|
|
|
|
jv = 0
|
|
|
|
jv = 0
|
|
|
|
for c in contours:
|
|
|
|
for c in contours:
|
|
|
@ -50,12 +50,12 @@ def filter_contours_area_of_image(image, contours, hirarchy, max_area, min_area)
|
|
|
|
|
|
|
|
|
|
|
|
polygon = geometry.Polygon([point[0] for point in c])
|
|
|
|
polygon = geometry.Polygon([point[0] for point in c])
|
|
|
|
area = polygon.area
|
|
|
|
area = polygon.area
|
|
|
|
if area >= min_area * np.prod(image.shape[:2]) and area <= max_area * np.prod(image.shape[:2]) and hirarchy[0][jv][3] == -1: # and hirarchy[0][jv][3]==-1 :
|
|
|
|
if area >= min_area * np.prod(image.shape[:2]) and area <= max_area * np.prod(image.shape[:2]) and hierarchy[0][jv][3] == -1: # and hirarchy[0][jv][3]==-1 :
|
|
|
|
found_polygons_early.append(np.array([[point] for point in polygon.exterior.coords], dtype=np.uint))
|
|
|
|
found_polygons_early.append(np.array([[point] for point in polygon.exterior.coords], dtype=np.uint))
|
|
|
|
jv += 1
|
|
|
|
jv += 1
|
|
|
|
return found_polygons_early
|
|
|
|
return found_polygons_early
|
|
|
|
|
|
|
|
|
|
|
|
def filter_contours_area_of_image_tables(image, contours, hirarchy, max_area, min_area):
|
|
|
|
def filter_contours_area_of_image_tables(image, contours, hierarchy, max_area, min_area):
|
|
|
|
found_polygons_early = list()
|
|
|
|
found_polygons_early = list()
|
|
|
|
|
|
|
|
|
|
|
|
jv = 0
|
|
|
|
jv = 0
|
|
|
@ -68,8 +68,8 @@ def filter_contours_area_of_image_tables(image, contours, hirarchy, max_area, mi
|
|
|
|
area = polygon.area
|
|
|
|
area = polygon.area
|
|
|
|
##print(np.prod(thresh.shape[:2]))
|
|
|
|
##print(np.prod(thresh.shape[:2]))
|
|
|
|
# Check that polygon has area greater than minimal area
|
|
|
|
# Check that polygon has area greater than minimal area
|
|
|
|
# print(hirarchy[0][jv][3],hirarchy )
|
|
|
|
# print(hierarchy[0][jv][3],hirarchy )
|
|
|
|
if area >= min_area * np.prod(image.shape[:2]) and area <= max_area * np.prod(image.shape[:2]): # and hirarchy[0][jv][3]==-1 :
|
|
|
|
if area >= min_area * np.prod(image.shape[:2]) and area <= max_area * np.prod(image.shape[:2]): # and hierarchy[0][jv][3]==-1 :
|
|
|
|
# print(c[0][0][1])
|
|
|
|
# print(c[0][0][1])
|
|
|
|
found_polygons_early.append(np.array([[point] for point in polygon.exterior.coords], dtype=np.int32))
|
|
|
|
found_polygons_early.append(np.array([[point] for point in polygon.exterior.coords], dtype=np.int32))
|
|
|
|
jv += 1
|
|
|
|
jv += 1
|
|
|
|