mirror of
https://github.com/qurator-spk/eynollah.git
synced 2025-09-06 15:59:57 +02:00
filter_contours_without_textline_inside: avoid removing from identical lists twice
This commit is contained in:
parent
698f38e461
commit
57821662b9
1 changed files with 16 additions and 16 deletions
|
@ -3764,7 +3764,9 @@ class Eynollah:
|
||||||
return contours
|
return contours
|
||||||
|
|
||||||
def filter_contours_without_textline_inside(
|
def filter_contours_without_textline_inside(
|
||||||
self, contours,text_con_org, contours_textline, contours_only_text_parent_d_ordered, conf_contours_textregions):
|
self, contours, text_con_org, contours_textline,
|
||||||
|
contours_only_text_parent_d_ordered,
|
||||||
|
conf_contours_textregions):
|
||||||
###contours_txtline_of_all_textregions = []
|
###contours_txtline_of_all_textregions = []
|
||||||
###for jj in range(len(contours_textline)):
|
###for jj in range(len(contours_textline)):
|
||||||
###contours_txtline_of_all_textregions = contours_txtline_of_all_textregions + contours_textline[jj]
|
###contours_txtline_of_all_textregions = contours_txtline_of_all_textregions + contours_textline[jj]
|
||||||
|
@ -3788,23 +3790,21 @@ class Eynollah:
|
||||||
###if np.any(results==1):
|
###if np.any(results==1):
|
||||||
###contours_with_textline.append(con_tr)
|
###contours_with_textline.append(con_tr)
|
||||||
|
|
||||||
textregion_index_to_del = []
|
textregion_index_to_del = set()
|
||||||
for index_textregion, textlines_textregion in enumerate(contours_textline):
|
for index_textregion, textlines_textregion in enumerate(contours_textline):
|
||||||
if len(textlines_textregion)==0:
|
if len(textlines_textregion) == 0:
|
||||||
textregion_index_to_del.append(index_textregion)
|
textregion_index_to_del.add(index_textregion)
|
||||||
|
def filterfun(lis):
|
||||||
|
if len(lis) == 0:
|
||||||
|
return []
|
||||||
|
return list(np.delete(lis, list(textregion_index_to_del)))
|
||||||
|
|
||||||
uniqe_args_trs = np.unique(textregion_index_to_del)
|
return (filterfun(contours),
|
||||||
uniqe_args_trs_sorted = np.sort(uniqe_args_trs)[::-1]
|
filterfun(text_con_org),
|
||||||
|
filterfun(conf_contours_textregions),
|
||||||
for ind_u_a_trs in uniqe_args_trs_sorted:
|
filterfun(contours_textline),
|
||||||
conf_contours_textregions.pop(ind_u_a_trs)
|
filterfun(contours_only_text_parent_d_ordered),
|
||||||
contours.pop(ind_u_a_trs)
|
np.arange(len(contours) - len(textregion_index_to_del)))
|
||||||
contours_textline.pop(ind_u_a_trs)
|
|
||||||
text_con_org.pop(ind_u_a_trs)
|
|
||||||
if len(contours_only_text_parent_d_ordered) > 0:
|
|
||||||
contours_only_text_parent_d_ordered.pop(ind_u_a_trs)
|
|
||||||
|
|
||||||
return contours, text_con_org, conf_contours_textregions, contours_textline, contours_only_text_parent_d_ordered, np.array(range(len(contours)))
|
|
||||||
|
|
||||||
def delete_regions_without_textlines(
|
def delete_regions_without_textlines(
|
||||||
self, slopes, all_found_textline_polygons, boxes_text, txt_con_org,
|
self, slopes, all_found_textline_polygons, boxes_text, txt_con_org,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue