mirror of
https://github.com/qurator-spk/eynollah.git
synced 2025-09-04 14:59:58 +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
|
||||
|
||||
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 = []
|
||||
###for jj in range(len(contours_textline)):
|
||||
###contours_txtline_of_all_textregions = contours_txtline_of_all_textregions + contours_textline[jj]
|
||||
|
@ -3788,23 +3790,21 @@ class Eynollah:
|
|||
###if np.any(results==1):
|
||||
###contours_with_textline.append(con_tr)
|
||||
|
||||
textregion_index_to_del = []
|
||||
textregion_index_to_del = set()
|
||||
for index_textregion, textlines_textregion in enumerate(contours_textline):
|
||||
if len(textlines_textregion)==0:
|
||||
textregion_index_to_del.append(index_textregion)
|
||||
if len(textlines_textregion) == 0:
|
||||
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)
|
||||
uniqe_args_trs_sorted = np.sort(uniqe_args_trs)[::-1]
|
||||
|
||||
for ind_u_a_trs in uniqe_args_trs_sorted:
|
||||
conf_contours_textregions.pop(ind_u_a_trs)
|
||||
contours.pop(ind_u_a_trs)
|
||||
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)))
|
||||
return (filterfun(contours),
|
||||
filterfun(text_con_org),
|
||||
filterfun(conf_contours_textregions),
|
||||
filterfun(contours_textline),
|
||||
filterfun(contours_only_text_parent_d_ordered),
|
||||
np.arange(len(contours) - len(textregion_index_to_del)))
|
||||
|
||||
def delete_regions_without_textlines(
|
||||
self, slopes, all_found_textline_polygons, boxes_text, txt_con_org,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue