Method evaluate_method: evaluate method and returns the results Results. Dictionary with the following values: - method (required) Global method metrics. Ex: { 'Precision':0.8,'Recall':0.9 } - samples (optional) Per sample metrics. Ex: {'sample1' : { 'Precision':0.8,'Re
(gtFilePath, submFilePath, evaluationParams)
| 55 | |
| 56 | |
| 57 | def evaluate_method(gtFilePath, submFilePath, evaluationParams): |
| 58 | """ |
| 59 | Method evaluate_method: evaluate method and returns the results |
| 60 | Results. Dictionary with the following values: |
| 61 | - method (required) Global method metrics. Ex: { 'Precision':0.8,'Recall':0.9 } |
| 62 | - samples (optional) Per sample metrics. Ex: {'sample1' : { 'Precision':0.8,'Recall':0.9 } , 'sample2' : { 'Precision':0.8,'Recall':0.9 } |
| 63 | """ |
| 64 | for module,alias in evaluation_imports().iteritems(): |
| 65 | globals()[alias] = importlib.import_module(module) |
| 66 | |
| 67 | def polygon_from_points(points,correctOffset=False): |
| 68 | """ |
| 69 | Returns a Polygon object to use with the Polygon2 class from a list of 8 points: x1,y1,x2,y2,x3,y3,x4,y4 |
| 70 | """ |
| 71 | |
| 72 | if correctOffset: #this will substract 1 from the coordinates that correspond to the xmax and ymax |
| 73 | points[2] -= 1 |
| 74 | points[4] -= 1 |
| 75 | points[5] -= 1 |
| 76 | points[7] -= 1 |
| 77 | |
| 78 | resBoxes=np.empty([1,8],dtype='int32') |
| 79 | resBoxes[0,0]=int(points[0]) |
| 80 | resBoxes[0,4]=int(points[1]) |
| 81 | resBoxes[0,1]=int(points[2]) |
| 82 | resBoxes[0,5]=int(points[3]) |
| 83 | resBoxes[0,2]=int(points[4]) |
| 84 | resBoxes[0,6]=int(points[5]) |
| 85 | resBoxes[0,3]=int(points[6]) |
| 86 | resBoxes[0,7]=int(points[7]) |
| 87 | pointMat = resBoxes[0].reshape([2,4]).T |
| 88 | return plg.Polygon( pointMat) |
| 89 | |
| 90 | def rectangle_to_polygon(rect): |
| 91 | resBoxes=np.empty([1,8],dtype='int32') |
| 92 | resBoxes[0,0]=int(rect.xmin) |
| 93 | resBoxes[0,4]=int(rect.ymax) |
| 94 | resBoxes[0,1]=int(rect.xmin) |
| 95 | resBoxes[0,5]=int(rect.ymin) |
| 96 | resBoxes[0,2]=int(rect.xmax) |
| 97 | resBoxes[0,6]=int(rect.ymin) |
| 98 | resBoxes[0,3]=int(rect.xmax) |
| 99 | resBoxes[0,7]=int(rect.ymax) |
| 100 | |
| 101 | pointMat = resBoxes[0].reshape([2,4]).T |
| 102 | |
| 103 | return plg.Polygon( pointMat) |
| 104 | |
| 105 | def rectangle_to_points(rect): |
| 106 | points = [int(rect.xmin), int(rect.ymax), int(rect.xmax), int(rect.ymax), int(rect.xmax), int(rect.ymin), int(rect.xmin), int(rect.ymin)] |
| 107 | return points |
| 108 | |
| 109 | def get_union(pD,pG): |
| 110 | areaA = pD.area(); |
| 111 | areaB = pG.area(); |
| 112 | return areaA + areaB - get_intersection(pD, pG); |
| 113 | |
| 114 | def get_intersection_over_union(pD,pG): |
nothing calls this directly
no test coverage detected