text = feature['TextNonText'] else: if 'properties' in feature and 'text' in feature['properties']: text = feature['properties']['text'] elif 'NameAfterDictionary' in feature: text = feature['NameBeforeDictionary'] else: print('Invalid file format.') quit() if text == 'NonText': text = "" for coordinate in feature['geometry']['coordinates']: text = text.lower() rect = ResultRectangle(coordinate, text) map_result_rects.append(rect) map_feature_list.append((i, rect)) result_area = rect.get_area() rect_gt_list = [] area_threshold = 0.7 gt_list = map_gt_list[i-1] for u in range(0, len(gt_list), 1): gt_rect_list = gt_list[u]['rects'] for j in range(0, len(gt_rect_list)): gt_rect = gt_rect_list[j] gt_area = gt_rect.get_area() overlap_polygon = rect.get_overlap_polygon(gt_rect) if overlap_polygon is None:
for row in score_reader: map_name = row[0] if map_name.find('.png') != -1: org_text, aligned, score = row[1 : 4] map_id = int(map_name.split('-')[1].split('.')[0]) x, y, w, h = row[4:] x = float(x) y = float(y) w = float(w) h = float(h) y *= -1 h *= -1 coordinates = [[x, y], [x + w, y], [x + w, y + h], [x, y + h], [x, y]] temp_rect = ResultRectangle(coordinates, org_text) matchFound = False sub = -1 for i, rect in enumerate(map_words_locations[map_id]): if temp_rect.is_the_same_rect(rect): matchFound = True sub = i break if not matchFound: # add new rect map_words_locations[map_id].append(temp_rect) map_max_scores[map_id].append(score) map_aligned_list[map_id].append([aligned]) map_org_texts[map_id].append(org_text)