Skip to content
Snippets Groups Projects
Commit 8d260488 authored by Luis Salamanca's avatar Luis Salamanca
Browse files

Possibility of only plotting lines or text boxes

parent e0ad9314
No related branches found
No related tags found
No related merge requests found
This diff is collapsed.
......@@ -583,8 +583,8 @@ class Document:
def plot_XMLcorrect(self, range_pages = range(1), suffix_xml = '_data',
flag_plot = 1, flag_save_figs = 0, name_outxml = '02_extractedxml',
name_outcorrxml = '04_correctedxml', flag_compute = 0):
name_outcorrxml = '04_correctedxml', flag_compute = 0, flag_lines_textl = 1):
# flag_lines_textl, if 1, plots lines and textboxes, if 2, only lines, if 3, only textboxes
if 'name_outxml' not in self.__dict__.keys():
self.name_outxml = name_outxml
if 'name_outcorrxml' not in self.__dict__.keys():
......@@ -603,7 +603,7 @@ class Document:
if flag_error:
print(str(ind_page) + ': non existing page!')
else:
im_met = plot_tools.plot_correctedXML(imarray, XML_enrich, bbox_page)
im_met = plot_tools.plot_correctedXML(imarray, XML_enrich, bbox_page, flag_lines_textl)
self._plot_save(im_met, 'XML corrected', 'XMLcorrect', ind_page, self.path_file,
flag_plot, flag_save_figs)
......
......@@ -226,7 +226,8 @@ def plot_horzvertlines(img, coord_horz, coord_vert_def):
return img_lines
def plot_correctedXML(img, XML_enrich, bbox_page):
def plot_correctedXML(img, XML_enrich, bbox_page, flag_lines_textl = 1):
# flag_lines_textl, if 1, plots lines and textboxes, if 2, only lines, if 3, only textboxes
# Essentially plotting the corrected textboxes and the lines from the
# final xml
img_xml = np.copy(img)
......@@ -234,10 +235,12 @@ def plot_correctedXML(img, XML_enrich, bbox_page):
if XML_enrich[0][ind_el].tag == 'textbox':
if 'bbox' in XML_enrich[0][ind_el].attrib:
coord_textbox = np.array(XML_enrich[0][ind_el].attrib['bbox'].split(',')).astype(np.float64)
if XML_enrich[0][ind_el].attrib['type_textbox'] == 'line':
img_xml = highlight_text(img_xml, coord_textbox, bbox_page, color_vec = 'blue', alpha = True, filled = False, thick_line = 6)
if XML_enrich[0][ind_el].attrib['type_textbox'] == 'text':
img_xml = highlight_text(img_xml, coord_textbox, bbox_page, color_vec = 'red', alpha = True, filled = False, thick_line = 6)
if flag_lines_textl < 3:
if XML_enrich[0][ind_el].attrib['type_textbox'] == 'line':
img_xml = highlight_text(img_xml, coord_textbox, bbox_page, color_vec = 'blue', alpha = True, filled = False, thick_line = 6)
if (flag_lines_textl == 1) or (flag_lines_textl == 3):
if XML_enrich[0][ind_el].attrib['type_textbox'] == 'text':
img_xml = highlight_text(img_xml, coord_textbox, bbox_page, color_vec = 'red', alpha = True, filled = False, thick_line = 6)
return img_xml
def plot_save_parallel(folder_pickles):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment