def evaluate_result(gt_obj, result_obj, group_para=0, scale_w=1, scale_h=1): gt_list = GeoJsonReader.get_ground_truth_list(gt_obj, scale_w, scale_h) result_rect_list = GeoJsonReader.get_result_rectangles(result_obj) return ResultEvaluation.evaluation_simple(result_rect_list, gt_list, area_threshold=0.7, group_para=group_para)
feature['geometry']['coordinates'][0]) new_phrase_dict['phrase'] = feature['NameAfterDictionary'] new_phrase_dict['rects'] = [new_gt_rect] new_phrase_dict['orientation'] = Orientation.ISOLATED new_phrase_dict['matching'] = [[]] new_phrase_dict['found'] = ['False'] new_phrase_dict['editing'] = [(0, 0, 0, 0)] gt_list.append(new_phrase_dict) return gt_list if __name__ == '__main__': groundTruthFile = sys.argv[1] resultFile = sys.argv[2] output_file = open("../Output/matching_list.txt", "w") result_obj = load_json_file(resultFile) gt_list = load_result_as_ground_truth(result_obj) gt_list = list(reversed(gt_list)) result_rect_list = get_result_rectangles(result_obj) ret = ResultEvaluation.find_result_ground_truth_correspondence(gt_list, result_rect_list) matching_lists = ret[0] for ml in matching_lists: for m in ml: output_str = str(m[0]) output_file.write(output_str) output_file.write("\n") output_file.write("\n")
print('eval ', mn) with open('./scores.csv') as csvfile: reader = csv.reader(csvfile, delimiter=',', quotechar='|') prev_result_file = './rsh_rs/' + map_name[i] + 'ByPixels.txt' groundTruthFile = './GroundTruths/' + map_name[i].split('.')[0] + '.geojson' prev_result_obj = GeoJsonReader.load_json_file(prev_result_file) gt_obj = GeoJsonReader.load_json_file(groundTruthFile) gt_list = GeoJsonReader.get_ground_truth_list(gt_obj, 1, 1) prev_result_rect_list = GeoJsonReader.get_result_rectangles(prev_result_obj) print('First eval') overlap_json, non_overlap_json, precision_list, recall_list, extracted_num_list, gt_num_list = \ ResultEvaluation.evaluation_simple(prev_result_rect_list, gt_list, area_threshold=0.6, group_para=0) # final_list = [] delete_list = [] for j, rect in enumerate(prev_result_rect_list): found_reverse = False for k, rect2 in enumerate(prev_result_rect_list): if j >= k: continue if rect.is_the_same_rect(rect2): sum1 = 0 for f in rect.textFound: sum1 += f