def post_process(matches):
 groups = _group_overlapping_rectangles(matches)
 for group_matches in groups.values():
  mins = numpy.stack((numpy.array(m[0]) for m in group_matches))
  maxs = numpy.stack((numpy.array(m[1]) for m in group_matches))
  present_probs = numpy.array([m[2] for m in group_matches])
  letter_probs = numpy.stack((m[3] for m in group_matches))
  (yield (numpy.max(mins, axis=0).flatten(), numpy.min(maxs, axis=0).flatten(), numpy.max(present_probs), letter_probs[numpy.argmax(present_probs)]))

def post_process ( matches ) : groups = _group_overlapping_rectangles ( matches ) for group_matches in groups . values ( ) : mins = numpy . stack ( ( numpy . array ( m [ 0 ] ) for m in group_matches ) ) maxs = numpy . stack ( ( numpy . array ( m [ 1 ] ) for m in group_matches ) ) present_probs = numpy . array ( [ m [ 2 ] for m in group_matches ] ) letter_probs = numpy . stack ( ( m [ 3 ] for m in group_matches ) ) ( yield ( numpy . max ( mins , axis = 0 ) . flatten ( ) , numpy . min ( maxs , axis = 0 ) . flatten ( ) , numpy . max ( present_probs ) , letter_probs [ numpy . argmax ( present_probs ) ] ) )
take an iterable of matches as returned by detect and merge duplicates .