mirror of
https://github.com/qurator-spk/eynollah.git
synced 2026-03-02 05:11:57 +01:00
get label for decoration without type attribute
This commit is contained in:
parent
c4434c7f7d
commit
0ca2d02ee8
2 changed files with 40 additions and 26 deletions
|
|
@ -356,11 +356,15 @@ def visualize_reading_order(xml_file, dir_xml, dir_out, dir_imgs):
|
||||||
layout = np.zeros( (y_len,x_len,3) )
|
layout = np.zeros( (y_len,x_len,3) )
|
||||||
layout = cv2.fillPoly(layout, pts =co_text_all, color=(1,1,1))
|
layout = cv2.fillPoly(layout, pts =co_text_all, color=(1,1,1))
|
||||||
|
|
||||||
|
try:
|
||||||
img_file_name_with_format = find_format_of_given_filename_in_dir(dir_imgs, f_name)
|
img_file_name_with_format = find_format_of_given_filename_in_dir(dir_imgs, f_name)
|
||||||
img = cv2.imread(os.path.join(dir_imgs, img_file_name_with_format))
|
img = cv2.imread(os.path.join(dir_imgs, img_file_name_with_format))
|
||||||
|
|
||||||
overlayed = overlay_layout_on_image(layout, img, cx_ordered, cy_ordered, color, thickness)
|
overlayed = overlay_layout_on_image(layout, img, cx_ordered, cy_ordered, color, thickness)
|
||||||
cv2.imwrite(os.path.join(dir_out, f_name+'.png'), overlayed)
|
cv2.imwrite(os.path.join(dir_out, f_name+'.png'), overlayed)
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
else:
|
else:
|
||||||
img = np.zeros( (y_len,x_len,3) )
|
img = np.zeros( (y_len,x_len,3) )
|
||||||
|
|
@ -415,6 +419,7 @@ def visualize_textline_segmentation(xml_file, dir_xml, dir_out, dir_imgs):
|
||||||
xml_file = os.path.join(dir_xml,ind_xml )
|
xml_file = os.path.join(dir_xml,ind_xml )
|
||||||
f_name = Path(ind_xml).stem
|
f_name = Path(ind_xml).stem
|
||||||
|
|
||||||
|
try:
|
||||||
img_file_name_with_format = find_format_of_given_filename_in_dir(dir_imgs, f_name)
|
img_file_name_with_format = find_format_of_given_filename_in_dir(dir_imgs, f_name)
|
||||||
img = cv2.imread(os.path.join(dir_imgs, img_file_name_with_format))
|
img = cv2.imread(os.path.join(dir_imgs, img_file_name_with_format))
|
||||||
|
|
||||||
|
|
@ -423,6 +428,8 @@ def visualize_textline_segmentation(xml_file, dir_xml, dir_out, dir_imgs):
|
||||||
added_image = visualize_image_from_contours(co_tetxlines, img)
|
added_image = visualize_image_from_contours(co_tetxlines, img)
|
||||||
|
|
||||||
cv2.imwrite(os.path.join(dir_out, f_name+'.png'), added_image)
|
cv2.imwrite(os.path.join(dir_out, f_name+'.png'), added_image)
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -472,15 +479,17 @@ def visualize_layout_segmentation(xml_file, dir_xml, dir_out, dir_imgs):
|
||||||
f_name = Path(ind_xml).stem
|
f_name = Path(ind_xml).stem
|
||||||
print(f_name, 'f_name')
|
print(f_name, 'f_name')
|
||||||
|
|
||||||
|
try:
|
||||||
img_file_name_with_format = find_format_of_given_filename_in_dir(dir_imgs, f_name)
|
img_file_name_with_format = find_format_of_given_filename_in_dir(dir_imgs, f_name)
|
||||||
img = cv2.imread(os.path.join(dir_imgs, img_file_name_with_format))
|
img = cv2.imread(os.path.join(dir_imgs, img_file_name_with_format))
|
||||||
|
|
||||||
co_text, co_graphic, co_sep, co_img, co_table, co_map, co_noise, y_len, x_len = get_layout_contours_for_visualization(xml_file)
|
co_text, co_graphic, co_sep, co_img, co_table, co_map, co_noise, y_len, x_len = get_layout_contours_for_visualization(xml_file)
|
||||||
|
|
||||||
|
|
||||||
added_image = visualize_image_from_contours_layout(co_text['paragraph'], co_text['header']+co_text['heading'], co_text['drop-capital'], co_sep, co_img, co_text['marginalia'], co_table, co_map, img)
|
added_image = visualize_image_from_contours_layout(co_text['paragraph'], co_text['header']+co_text['heading'], co_text['drop-capital'], co_sep, co_img, co_text['marginalia'], co_table, co_map, img)
|
||||||
|
|
||||||
cv2.imwrite(os.path.join(dir_out, f_name+'.png'), added_image)
|
cv2.imwrite(os.path.join(dir_out, f_name+'.png'), added_image)
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -969,7 +969,7 @@ def get_images_of_ground_truth(gt_list, dir_in, output_dir, output_type, config_
|
||||||
if "rest_as_decoration" in types_graphic:
|
if "rest_as_decoration" in types_graphic:
|
||||||
types_graphic_without_decoration = [element for element in types_graphic if element!='rest_as_decoration' and element!='decoration']
|
types_graphic_without_decoration = [element for element in types_graphic if element!='rest_as_decoration' and element!='decoration']
|
||||||
if len(types_graphic_without_decoration) == 0:
|
if len(types_graphic_without_decoration) == 0:
|
||||||
if "type" in nn.attrib:
|
#if "type" in nn.attrib:
|
||||||
c_t_in_graphic['decoration'].append( np.array( [ [ int(x.split(',')[0]) , int(x.split(',')[1]) ] for x in p_h] ) )
|
c_t_in_graphic['decoration'].append( np.array( [ [ int(x.split(',')[0]) , int(x.split(',')[1]) ] for x in p_h] ) )
|
||||||
elif len(types_graphic_without_decoration) >= 1:
|
elif len(types_graphic_without_decoration) >= 1:
|
||||||
if "type" in nn.attrib:
|
if "type" in nn.attrib:
|
||||||
|
|
@ -977,12 +977,14 @@ def get_images_of_ground_truth(gt_list, dir_in, output_dir, output_type, config_
|
||||||
c_t_in_graphic[nn.attrib['type']].append( np.array( [ [ int(x.split(',')[0]) , int(x.split(',')[1]) ] for x in p_h] ) )
|
c_t_in_graphic[nn.attrib['type']].append( np.array( [ [ int(x.split(',')[0]) , int(x.split(',')[1]) ] for x in p_h] ) )
|
||||||
else:
|
else:
|
||||||
c_t_in_graphic['decoration'].append( np.array( [ [ int(x.split(',')[0]) , int(x.split(',')[1]) ] for x in p_h] ) )
|
c_t_in_graphic['decoration'].append( np.array( [ [ int(x.split(',')[0]) , int(x.split(',')[1]) ] for x in p_h] ) )
|
||||||
|
else:
|
||||||
|
c_t_in_graphic['decoration'].append( np.array( [ [ int(x.split(',')[0]) , int(x.split(',')[1]) ] for x in p_h] ) )
|
||||||
else:
|
else:
|
||||||
if "type" in nn.attrib:
|
if "type" in nn.attrib:
|
||||||
if nn.attrib['type'] in all_defined_graphic_types:
|
if nn.attrib['type'] in all_defined_graphic_types:
|
||||||
c_t_in_graphic[nn.attrib['type']].append( np.array( [ [ int(x.split(',')[0]) , int(x.split(',')[1]) ] for x in p_h] ) )
|
c_t_in_graphic[nn.attrib['type']].append( np.array( [ [ int(x.split(',')[0]) , int(x.split(',')[1]) ] for x in p_h] ) )
|
||||||
|
|
||||||
|
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
pass
|
pass
|
||||||
|
|
@ -992,7 +994,7 @@ def get_images_of_ground_truth(gt_list, dir_in, output_dir, output_type, config_
|
||||||
if "rest_as_decoration" in types_graphic:
|
if "rest_as_decoration" in types_graphic:
|
||||||
types_graphic_without_decoration = [element for element in types_graphic if element!='rest_as_decoration' and element!='decoration']
|
types_graphic_without_decoration = [element for element in types_graphic if element!='rest_as_decoration' and element!='decoration']
|
||||||
if len(types_graphic_without_decoration) == 0:
|
if len(types_graphic_without_decoration) == 0:
|
||||||
if "type" in nn.attrib:
|
#if "type" in nn.attrib:
|
||||||
c_t_in_graphic['decoration'].append( [ int(float(vv.attrib['x'])) , int(float(vv.attrib['y'])) ] )
|
c_t_in_graphic['decoration'].append( [ int(float(vv.attrib['x'])) , int(float(vv.attrib['y'])) ] )
|
||||||
sumi+=1
|
sumi+=1
|
||||||
elif len(types_graphic_without_decoration) >= 1:
|
elif len(types_graphic_without_decoration) >= 1:
|
||||||
|
|
@ -1003,6 +1005,9 @@ def get_images_of_ground_truth(gt_list, dir_in, output_dir, output_type, config_
|
||||||
else:
|
else:
|
||||||
c_t_in_graphic['decoration'].append( [ int(float(vv.attrib['x'])) , int(float(vv.attrib['y'])) ] )
|
c_t_in_graphic['decoration'].append( [ int(float(vv.attrib['x'])) , int(float(vv.attrib['y'])) ] )
|
||||||
sumi+=1
|
sumi+=1
|
||||||
|
else:
|
||||||
|
c_t_in_graphic['decoration'].append( [ int(float(vv.attrib['x'])) , int(float(vv.attrib['y'])) ] )
|
||||||
|
sumi+=1
|
||||||
|
|
||||||
else:
|
else:
|
||||||
if "type" in nn.attrib:
|
if "type" in nn.attrib:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue