|
|
@ -1161,7 +1161,7 @@ class eynollah:
|
|
|
|
self.logger.debug('enter serialize_lines_in_region')
|
|
|
|
self.logger.debug('enter serialize_lines_in_region')
|
|
|
|
for j in range(len(all_found_texline_polygons[region_idx])):
|
|
|
|
for j in range(len(all_found_texline_polygons[region_idx])):
|
|
|
|
textline = ET.SubElement(textregion, 'TextLine')
|
|
|
|
textline = ET.SubElement(textregion, 'TextLine')
|
|
|
|
textline.set('id','l'+str(id_indexer_l))
|
|
|
|
textline.set('id', 'l%s' % id_indexer_l)
|
|
|
|
id_indexer_l += 1
|
|
|
|
id_indexer_l += 1
|
|
|
|
coord = ET.SubElement(textline, 'Coords')
|
|
|
|
coord = ET.SubElement(textline, 'Coords')
|
|
|
|
add_textequiv(textline)
|
|
|
|
add_textequiv(textline)
|
|
|
@ -1169,66 +1169,37 @@ class eynollah:
|
|
|
|
points_co = ''
|
|
|
|
points_co = ''
|
|
|
|
for l in range(len(all_found_texline_polygons[region_idx][j])):
|
|
|
|
for l in range(len(all_found_texline_polygons[region_idx][j])):
|
|
|
|
if not self.curved_line:
|
|
|
|
if not self.curved_line:
|
|
|
|
#point.set('x',str(found_polygons[j][l][0]))
|
|
|
|
|
|
|
|
#point.set('y',str(found_polygons[j][l][1]))
|
|
|
|
|
|
|
|
if len(all_found_texline_polygons[region_idx][j][l])==2:
|
|
|
|
if len(all_found_texline_polygons[region_idx][j][l])==2:
|
|
|
|
textline_x_coord=int( (all_found_texline_polygons[region_idx][j][l][0]
|
|
|
|
textline_x_coord = max(0, int((all_found_texline_polygons[region_idx][j][l][0] + all_box_coord[region_idx][2] + page_coord[2]) / self.scale_x))
|
|
|
|
+all_box_coord[region_idx][2]+page_coord[2])/self.scale_x)
|
|
|
|
textline_y_coord = max(0, int((all_found_texline_polygons[region_idx][j][l][1] + all_box_coord[region_idx][0] + page_coord[0]) / self.scale_y))
|
|
|
|
textline_y_coord=int( (all_found_texline_polygons[region_idx][j][l][1]
|
|
|
|
|
|
|
|
+all_box_coord[region_idx][0]+page_coord[0])/self.scale_y)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if textline_x_coord<0:
|
|
|
|
|
|
|
|
textline_x_coord=0
|
|
|
|
|
|
|
|
if textline_y_coord<0:
|
|
|
|
|
|
|
|
textline_y_coord=0
|
|
|
|
|
|
|
|
points_co=points_co+str( textline_x_coord )
|
|
|
|
|
|
|
|
points_co=points_co+','
|
|
|
|
|
|
|
|
points_co=points_co+str( textline_y_coord )
|
|
|
|
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
|
|
|
|
textline_x_coord = max(0, int((all_found_texline_polygons[region_idx][j][l][0][0] + all_box_coord[region_idx][2] + page_coord[2]) / self.scale_x))
|
|
|
|
|
|
|
|
textline_y_coord = max(0, int((all_found_texline_polygons[region_idx][j][l][0][1] + all_box_coord[region_idx][0] + page_coord[0]) / self.scale_y))
|
|
|
|
|
|
|
|
points_co += str(textline_x_coord)
|
|
|
|
|
|
|
|
points_co += ','
|
|
|
|
|
|
|
|
points_co += str(textline_y_coord)
|
|
|
|
|
|
|
|
|
|
|
|
textline_x_coord=int( ( all_found_texline_polygons[region_idx][j][l][0][0]
|
|
|
|
if self.curved_line and np.abs(slopes[region_idx]) <= 45:
|
|
|
|
+all_box_coord[region_idx][2]+page_coord[2])/self.scale_x )
|
|
|
|
|
|
|
|
textline_y_coord=int( ( all_found_texline_polygons[region_idx][j][l][0][1]
|
|
|
|
|
|
|
|
+all_box_coord[region_idx][0]+page_coord[0])/self.scale_y)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if textline_x_coord<0:
|
|
|
|
|
|
|
|
textline_x_coord=0
|
|
|
|
|
|
|
|
if textline_y_coord<0:
|
|
|
|
|
|
|
|
textline_y_coord=0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
points_co=points_co+str( textline_x_coord )
|
|
|
|
|
|
|
|
points_co=points_co+','
|
|
|
|
|
|
|
|
points_co=points_co+str( textline_y_coord )
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (self.curved_line) and np.abs(slopes[region_idx]) <= 45 :
|
|
|
|
|
|
|
|
if len(all_found_texline_polygons[region_idx][j][l]) == 2:
|
|
|
|
if len(all_found_texline_polygons[region_idx][j][l]) == 2:
|
|
|
|
points_co=points_co+str( int( (all_found_texline_polygons[region_idx][j][l][0]
|
|
|
|
points_co += str(int((all_found_texline_polygons[region_idx][j][l][0] + page_coord[2]) / self.scale_x))
|
|
|
|
+page_coord[2])/self.scale_x) )
|
|
|
|
points_co += ','
|
|
|
|
points_co=points_co+','
|
|
|
|
points_co += str(int((all_found_texline_polygons[region_idx][j][l][1] + page_coord[0]) / self.scale_y))
|
|
|
|
points_co=points_co+str( int( (all_found_texline_polygons[region_idx][j][l][1]
|
|
|
|
|
|
|
|
+page_coord[0])/self.scale_y) )
|
|
|
|
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
points_co=points_co+str( int( ( all_found_texline_polygons[region_idx][j][l][0][0]
|
|
|
|
points_co += str(int((all_found_texline_polygons[region_idx][j][l][0][0] + page_coord[2]) / self.scale_x))
|
|
|
|
+page_coord[2])/self.scale_x ) )
|
|
|
|
points_co += ','
|
|
|
|
points_co=points_co+','
|
|
|
|
points_co += str(int((all_found_texline_polygons[region_idx][j][l][0][1] + page_coord[0])/self.scale_y))
|
|
|
|
points_co=points_co+str( int( ( all_found_texline_polygons[region_idx][j][l][0][1]
|
|
|
|
elif self.curved_line and np.abs(slopes[region_idx]) > 45:
|
|
|
|
+page_coord[0])/self.scale_y) )
|
|
|
|
|
|
|
|
elif (self.curved_line) and np.abs(slopes[region_idx]) > 45 :
|
|
|
|
|
|
|
|
if len(all_found_texline_polygons[region_idx][j][l])==2:
|
|
|
|
if len(all_found_texline_polygons[region_idx][j][l])==2:
|
|
|
|
points_co=points_co+str( int( (all_found_texline_polygons[region_idx][j][l][0]
|
|
|
|
points_co += str(int((all_found_texline_polygons[region_idx][j][l][0] + all_box_coord[region_idx][2]+page_coord[2])/self.scale_x))
|
|
|
|
+all_box_coord[region_idx][2]+page_coord[2])/self.scale_x) )
|
|
|
|
points_co += ','
|
|
|
|
points_co=points_co+','
|
|
|
|
points_co += str(int((all_found_texline_polygons[region_idx][j][l][1] + all_box_coord[region_idx][0]+page_coord[0])/self.scale_y))
|
|
|
|
points_co=points_co+str( int( (all_found_texline_polygons[region_idx][j][l][1]
|
|
|
|
|
|
|
|
+all_box_coord[region_idx][0]+page_coord[0])/self.scale_y) )
|
|
|
|
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
points_co=points_co+str( int( ( all_found_texline_polygons[region_idx][j][l][0][0]
|
|
|
|
points_co += str(int((all_found_texline_polygons[region_idx][j][l][0][0] + all_box_coord[region_idx][2]+page_coord[2])/self.scale_x))
|
|
|
|
+all_box_coord[region_idx][2]+page_coord[2])/self.scale_x ) )
|
|
|
|
points_co += ','
|
|
|
|
points_co=points_co+','
|
|
|
|
points_co += str(int((all_found_texline_polygons[region_idx][j][l][0][1] + all_box_coord[region_idx][0]+page_coord[0])/self.scale_y))
|
|
|
|
points_co=points_co+str( int( ( all_found_texline_polygons[region_idx][j][l][0][1]
|
|
|
|
|
|
|
|
+all_box_coord[region_idx][0]+page_coord[0])/self.scale_y) )
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if l<(len(all_found_texline_polygons[region_idx][j])-1):
|
|
|
|
if l < len(all_found_texline_polygons[region_idx][j]) - 1:
|
|
|
|
points_co=points_co+' '
|
|
|
|
points_co += ' '
|
|
|
|
coord.set('points',points_co)
|
|
|
|
coord.set('points',points_co)
|
|
|
|
return id_indexer_l
|
|
|
|
return id_indexer_l
|
|
|
|
|
|
|
|
|
|
|
@ -1263,7 +1234,7 @@ class eynollah:
|
|
|
|
points_page_print += ','
|
|
|
|
points_page_print += ','
|
|
|
|
points_page_print += str(int((self.cont_page[0][lmm][0][1] ) / self.scale_y))
|
|
|
|
points_page_print += str(int((self.cont_page[0][lmm][0][1] ) / self.scale_y))
|
|
|
|
|
|
|
|
|
|
|
|
if lmm < (len( self.cont_page[0] ) - 1):
|
|
|
|
if lmm < len( self.cont_page[0] ) - 1:
|
|
|
|
points_page_print = points_page_print + ' '
|
|
|
|
points_page_print = points_page_print + ' '
|
|
|
|
return points_page_print
|
|
|
|
return points_page_print
|
|
|
|
|
|
|
|
|
|
|
@ -1324,7 +1295,6 @@ class eynollah:
|
|
|
|
if len(all_found_texline_polygons[mm][j][l]) == 2:
|
|
|
|
if len(all_found_texline_polygons[mm][j][l]) == 2:
|
|
|
|
textline_x_coord = max(0, int((all_found_texline_polygons[mm][j][l][0] + all_box_coord[mm][2] + page_coord[2]) / self.scale_x))
|
|
|
|
textline_x_coord = max(0, int((all_found_texline_polygons[mm][j][l][0] + all_box_coord[mm][2] + page_coord[2]) / self.scale_x))
|
|
|
|
textline_y_coord = max(0, int((all_found_texline_polygons[mm][j][l][1] + all_box_coord[mm][0] + page_coord[0]) / self.scale_y))
|
|
|
|
textline_y_coord = max(0, int((all_found_texline_polygons[mm][j][l][1] + all_box_coord[mm][0] + page_coord[0]) / self.scale_y))
|
|
|
|
points_co += str(textline_x_coord) + ',' + str(textline_y_coord)
|
|
|
|
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
textline_x_coord = max(0, int((all_found_texline_polygons[mm][j][l][0][0] + all_box_coord[mm][2]+page_coord[2]) / self.scale_x))
|
|
|
|
textline_x_coord = max(0, int((all_found_texline_polygons[mm][j][l][0][0] + all_box_coord[mm][2]+page_coord[2]) / self.scale_x))
|
|
|
|
textline_y_coord = max(0, int((all_found_texline_polygons[mm][j][l][0][1] + all_box_coord[mm][0]+page_coord[0]) / self.scale_y))
|
|
|
|
textline_y_coord = max(0, int((all_found_texline_polygons[mm][j][l][0][1] + all_box_coord[mm][0]+page_coord[0]) / self.scale_y))
|
|
|
@ -1491,7 +1461,7 @@ class eynollah:
|
|
|
|
points_co += ','
|
|
|
|
points_co += ','
|
|
|
|
points_co += str(int((all_found_texline_polygons_marginals[mm][j][l][0][1] + page_coord[0]) / self.scale_y))
|
|
|
|
points_co += str(int((all_found_texline_polygons_marginals[mm][j][l][0][1] + page_coord[0]) / self.scale_y))
|
|
|
|
|
|
|
|
|
|
|
|
if l<(len(all_found_texline_polygons_marginals[mm][j])-1):
|
|
|
|
if l < len(all_found_texline_polygons_marginals[mm][j]) - 1:
|
|
|
|
points_co = points_co+' '
|
|
|
|
points_co = points_co+' '
|
|
|
|
coord.set('points',points_co)
|
|
|
|
coord.set('points',points_co)
|
|
|
|
add_textequiv(textregion)
|
|
|
|
add_textequiv(textregion)
|
|
|
|