@ -1,7 +1,7 @@
import numpy as np
import numpy as np
import cv2
import cv2
from . contour import (
from . contour import (
find_new_features_of_contour e s,
find_new_features_of_contour s,
return_contours_of_image ,
return_contours_of_image ,
return_parent_contours ,
return_parent_contours ,
)
)
@ -20,9 +20,9 @@ def adhere_drop_capital_region_into_corresponding_textline(
) :
) :
# print(np.shape(all_found_texline_polygons),np.shape(all_found_texline_polygons[3]),'all_found_texline_polygonsshape')
# print(np.shape(all_found_texline_polygons),np.shape(all_found_texline_polygons[3]),'all_found_texline_polygonsshape')
# print(all_found_texline_polygons[3])
# print(all_found_texline_polygons[3])
cx_m , cy_m , _ , _ , _ , _ , _ = find_new_features_of_contour e s( contours_only_text_parent )
cx_m , cy_m , _ , _ , _ , _ , _ = find_new_features_of_contour s( contours_only_text_parent )
cx_h , cy_h , _ , _ , _ , _ , _ = find_new_features_of_contour e s( contours_only_text_parent_h )
cx_h , cy_h , _ , _ , _ , _ , _ = find_new_features_of_contour s( contours_only_text_parent_h )
cx_d , cy_d , _ , _ , y_min_d , y_max_d , _ = find_new_features_of_contour e s( polygons_of_drop_capitals )
cx_d , cy_d , _ , _ , y_min_d , y_max_d , _ = find_new_features_of_contour s( polygons_of_drop_capitals )
img_con_all = np . zeros ( ( text_regions_p . shape [ 0 ] , text_regions_p . shape [ 1 ] , 3 ) )
img_con_all = np . zeros ( ( text_regions_p . shape [ 0 ] , text_regions_p . shape [ 1 ] , 3 ) )
for j_cont in range ( len ( contours_only_text_parent ) ) :
for j_cont in range ( len ( contours_only_text_parent ) ) :
@ -87,9 +87,9 @@ def adhere_drop_capital_region_into_corresponding_textline(
region_final = region_with_intersected_drop [ np . argmax ( sum_pixels_of_intersection ) ] - 1
region_final = region_with_intersected_drop [ np . argmax ( sum_pixels_of_intersection ) ] - 1
# print(region_final,'region_final')
# print(region_final,'region_final')
# cx_t,cy_t ,_, _, _ ,_,_= find_new_features_of_contour e s(all_found_texline_polygons[int(region_final)])
# cx_t,cy_t ,_, _, _ ,_,_= find_new_features_of_contour s(all_found_texline_polygons[int(region_final)])
try :
try :
cx_t , cy_t , _ , _ , _ , _ , _ = find_new_features_of_contour e s( all_found_texline_polygons [ int ( region_final ) ] )
cx_t , cy_t , _ , _ , _ , _ , _ = find_new_features_of_contour s( all_found_texline_polygons [ int ( region_final ) ] )
# print(all_box_coord[j_cont])
# print(all_box_coord[j_cont])
# print(cx_t)
# print(cx_t)
# print(cy_t)
# print(cy_t)
@ -141,9 +141,9 @@ def adhere_drop_capital_region_into_corresponding_textline(
# areas_main=np.array([cv2.contourArea(all_found_texline_polygons[int(region_final)][0][j] ) for j in range(len(all_found_texline_polygons[int(region_final)]))])
# areas_main=np.array([cv2.contourArea(all_found_texline_polygons[int(region_final)][0][j] ) for j in range(len(all_found_texline_polygons[int(region_final)]))])
# cx_t,cy_t ,_, _, _ ,_,_= find_new_features_of_contour e s(all_found_texline_polygons[int(region_final)])
# cx_t,cy_t ,_, _, _ ,_,_= find_new_features_of_contour s(all_found_texline_polygons[int(region_final)])
cx_t , cy_t , _ , _ , _ , _ , _ = find_new_features_of_contour e s( all_found_texline_polygons [ int ( region_final ) ] )
cx_t , cy_t , _ , _ , _ , _ , _ = find_new_features_of_contour s( all_found_texline_polygons [ int ( region_final ) ] )
# print(all_box_coord[j_cont])
# print(all_box_coord[j_cont])
# print(cx_t)
# print(cx_t)
# print(cy_t)
# print(cy_t)
@ -191,7 +191,7 @@ def adhere_drop_capital_region_into_corresponding_textline(
# print(cx_t,'print')
# print(cx_t,'print')
try :
try :
# print(all_found_texline_polygons[j_cont][0])
# print(all_found_texline_polygons[j_cont][0])
cx_t , cy_t , _ , _ , _ , _ , _ = find_new_features_of_contour e s( all_found_texline_polygons [ int ( region_final ) ] )
cx_t , cy_t , _ , _ , _ , _ , _ = find_new_features_of_contour s( all_found_texline_polygons [ int ( region_final ) ] )
# print(all_box_coord[j_cont])
# print(all_box_coord[j_cont])
# print(cx_t)
# print(cx_t)
# print(cy_t)
# print(cy_t)
@ -238,7 +238,7 @@ def adhere_drop_capital_region_into_corresponding_textline(
else :
else :
pass
pass
##cx_t,cy_t ,_, _, _ ,_,_= find_new_features_of_contour e s(all_found_texline_polygons[int(region_final)])
##cx_t,cy_t ,_, _, _ ,_,_= find_new_features_of_contour s(all_found_texline_polygons[int(region_final)])
###print(all_box_coord[j_cont])
###print(all_box_coord[j_cont])
###print(cx_t)
###print(cx_t)
###print(cy_t)
###print(cy_t)
@ -292,9 +292,9 @@ def adhere_drop_capital_region_into_corresponding_textline(
region_final = region_with_intersected_drop [ np . argmax ( sum_pixels_of_intersection ) ] - 1
region_final = region_with_intersected_drop [ np . argmax ( sum_pixels_of_intersection ) ] - 1
# print(region_final,'region_final')
# print(region_final,'region_final')
# cx_t,cy_t ,_, _, _ ,_,_= find_new_features_of_contour e s(all_found_texline_polygons[int(region_final)])
# cx_t,cy_t ,_, _, _ ,_,_= find_new_features_of_contour s(all_found_texline_polygons[int(region_final)])
try :
try :
cx_t , cy_t , _ , _ , _ , _ , _ = find_new_features_of_contour e s( all_found_texline_polygons [ int ( region_final ) ] )
cx_t , cy_t , _ , _ , _ , _ , _ = find_new_features_of_contour s( all_found_texline_polygons [ int ( region_final ) ] )
# print(all_box_coord[j_cont])
# print(all_box_coord[j_cont])
# print(cx_t)
# print(cx_t)
# print(cy_t)
# print(cy_t)
@ -346,12 +346,12 @@ def adhere_drop_capital_region_into_corresponding_textline(
# areas_main=np.array([cv2.contourArea(all_found_texline_polygons[int(region_final)][0][j] ) for j in range(len(all_found_texline_polygons[int(region_final)]))])
# areas_main=np.array([cv2.contourArea(all_found_texline_polygons[int(region_final)][0][j] ) for j in range(len(all_found_texline_polygons[int(region_final)]))])
# cx_t,cy_t ,_, _, _ ,_,_= find_new_features_of_contour e s(all_found_texline_polygons[int(region_final)])
# cx_t,cy_t ,_, _, _ ,_,_= find_new_features_of_contour s(all_found_texline_polygons[int(region_final)])
# print(cx_t,'print')
# print(cx_t,'print')
try :
try :
# print(all_found_texline_polygons[j_cont][0])
# print(all_found_texline_polygons[j_cont][0])
cx_t , cy_t , _ , _ , _ , _ , _ = find_new_features_of_contour e s( all_found_texline_polygons [ int ( region_final ) ] )
cx_t , cy_t , _ , _ , _ , _ , _ = find_new_features_of_contour s( all_found_texline_polygons [ int ( region_final ) ] )
# print(all_box_coord[j_cont])
# print(all_box_coord[j_cont])
# print(cx_t)
# print(cx_t)
# print(cy_t)
# print(cy_t)
@ -417,7 +417,7 @@ def adhere_drop_capital_region_into_corresponding_textline(
#####try:
#####try:
#####if len(contours_new_parent)==1:
#####if len(contours_new_parent)==1:
######print(all_found_texline_polygons[j_cont][0])
######print(all_found_texline_polygons[j_cont][0])
#####cx_t,cy_t ,_, _, _ ,_,_= find_new_features_of_contour e s(all_found_texline_polygons[j_cont])
#####cx_t,cy_t ,_, _, _ ,_,_= find_new_features_of_contour s(all_found_texline_polygons[j_cont])
######print(all_box_coord[j_cont])
######print(all_box_coord[j_cont])
######print(cx_t)
######print(cx_t)
######print(cy_t)
######print(cy_t)