mirror of
https://github.com/qurator-spk/eynollah.git
synced 2026-03-01 21:02:00 +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 = cv2.fillPoly(layout, pts =co_text_all, color=(1,1,1))
|
||||
|
||||
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))
|
||||
|
||||
overlayed = overlay_layout_on_image(layout, img, cx_ordered, cy_ordered, color, thickness)
|
||||
cv2.imwrite(os.path.join(dir_out, f_name+'.png'), overlayed)
|
||||
try:
|
||||
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))
|
||||
|
||||
overlayed = overlay_layout_on_image(layout, img, cx_ordered, cy_ordered, color, thickness)
|
||||
cv2.imwrite(os.path.join(dir_out, f_name+'.png'), overlayed)
|
||||
except:
|
||||
pass
|
||||
|
||||
|
||||
else:
|
||||
img = np.zeros( (y_len,x_len,3) )
|
||||
|
|
@ -415,14 +419,17 @@ def visualize_textline_segmentation(xml_file, dir_xml, dir_out, dir_imgs):
|
|||
xml_file = os.path.join(dir_xml,ind_xml )
|
||||
f_name = Path(ind_xml).stem
|
||||
|
||||
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))
|
||||
try:
|
||||
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))
|
||||
|
||||
co_tetxlines, y_len, x_len = get_textline_contours_for_visualization(xml_file)
|
||||
|
||||
co_tetxlines, y_len, x_len = get_textline_contours_for_visualization(xml_file)
|
||||
|
||||
added_image = visualize_image_from_contours(co_tetxlines, img)
|
||||
|
||||
cv2.imwrite(os.path.join(dir_out, f_name+'.png'), added_image)
|
||||
added_image = visualize_image_from_contours(co_tetxlines, img)
|
||||
|
||||
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
|
||||
print(f_name, '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))
|
||||
try:
|
||||
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))
|
||||
|
||||
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,19 +969,21 @@ def get_images_of_ground_truth(gt_list, dir_in, output_dir, output_type, config_
|
|||
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']
|
||||
if len(types_graphic_without_decoration) == 0:
|
||||
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] ) )
|
||||
#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] ) )
|
||||
elif len(types_graphic_without_decoration) >= 1:
|
||||
if "type" in nn.attrib:
|
||||
if nn.attrib['type'] in types_graphic_without_decoration:
|
||||
c_t_in_graphic[nn.attrib['type']].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:
|
||||
c_t_in_graphic['decoration'].append( np.array( [ [ int(x.split(',')[0]) , int(x.split(',')[1]) ] for x in p_h] ) )
|
||||
else:
|
||||
if "type" in nn.attrib:
|
||||
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
|
||||
else:
|
||||
|
|
@ -992,9 +994,9 @@ def get_images_of_ground_truth(gt_list, dir_in, output_dir, output_type, config_
|
|||
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']
|
||||
if len(types_graphic_without_decoration) == 0:
|
||||
if "type" in nn.attrib:
|
||||
c_t_in_graphic['decoration'].append( [ int(float(vv.attrib['x'])) , int(float(vv.attrib['y'])) ] )
|
||||
sumi+=1
|
||||
#if "type" in nn.attrib:
|
||||
c_t_in_graphic['decoration'].append( [ int(float(vv.attrib['x'])) , int(float(vv.attrib['y'])) ] )
|
||||
sumi+=1
|
||||
elif len(types_graphic_without_decoration) >= 1:
|
||||
if "type" in nn.attrib:
|
||||
if nn.attrib['type'] in types_graphic_without_decoration:
|
||||
|
|
@ -1003,6 +1005,9 @@ def get_images_of_ground_truth(gt_list, dir_in, output_dir, output_type, config_
|
|||
else:
|
||||
c_t_in_graphic['decoration'].append( [ int(float(vv.attrib['x'])) , int(float(vv.attrib['y'])) ] )
|
||||
sumi+=1
|
||||
else:
|
||||
c_t_in_graphic['decoration'].append( [ int(float(vv.attrib['x'])) , int(float(vv.attrib['y'])) ] )
|
||||
sumi+=1
|
||||
|
||||
else:
|
||||
if "type" in nn.attrib:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue