Example #1
0
 def test_calc_center_dist(self):
     pred = Prediction(13.88, 0, 10, 0.58)
     lbl = Label(0, 0, 10)
     pred.matched_label = lbl
     self.assertEquals(pred.center_dist, None)
     pred.calc_center_dist()
     self.assertEquals(pred.center_dist, 13.88)
Example #2
0
def parse_labels(labels_path):
    """
    Returns a list of Label objects parsed from a given txt file
    :param labels_path: The path to the txt file that contains labels in the (x, y, r) format.
    The labels are line separated and the coordinates are space separated.
    :return: A list of Label objects parsed from the given file.
    """
    labels = []
    with open(labels_path, 'r') as gt_f:
        for line in gt_f.readlines():
            label = line.split()
            labels.append(Label(int(label[0]), int(label[1]), float(label[2])))
    return labels
Example #3
0
 def test_calc_rect_iou(self):
     pred = Prediction(0, 0, 10, 0.58)
     lbl = Label(0, 5, 10)
     iou = pred.calc_rect_iou(lbl)
     self.assertAlmostEqual(iou, 0.6, 1)
Example #4
0
 def test_calc_circle_iou_zero_both_radius(self):
     pred = Prediction(0, 0, 0, 0.58)
     lbl = Label(0, 0, 0)
     iou = pred.calc_circle_iou(lbl)
     self.assertAlmostEqual(iou, 1)
Example #5
0
 def test_calc_circle_iou_fully_intersecting(self):
     pred = Prediction(0, 0, 10, 0.58)
     lbl = Label(0, 0, 10)
     iou = pred.calc_circle_iou(lbl)
     self.assertAlmostEqual(iou, 1)
Example #6
0
 def test_calc_circle_iou_one_inside_other_not_centered_2(self):
     pred = Prediction(0, 0.1, 20, 0.58)
     lbl = Label(0, 0, 5)
     iou = pred.calc_circle_iou(lbl)
     self.assertAlmostEqual(iou, 0.0625)
Example #7
0
 def test_calc_circle_iou_one_inside_other(self):
     pred = Prediction(0, 0, 10, 0.58)
     lbl = Label(0, 0, 20)
     iou = pred.calc_circle_iou(lbl)
     self.assertAlmostEqual(iou, 0.25)
Example #8
0
 def test_calc_circle_iou_not_even_close(self):
     pred = Prediction(50, 0, 10, 0.58)
     lbl = Label(0, 0, 10)
     iou = pred.calc_circle_iou(lbl)
     self.assertAlmostEqual(iou, 0)