def test_build_matrices(): gt_poly, det_poly = ObjectAreaEvaluator.prune_and_polygon( kGroundTruth, kDetected) gt_matrix, det_matrix = ObjectAreaEvaluator.build_matrices( gt_poly, det_poly) assert np.allclose(gt_matrix, kMatchMatrixGroundTruth) assert np.allclose(det_matrix, kMatchMatrixDetections)
def test_non_zero_polygon_zero_area_with_warning(capfd): result = ObjectAreaEvaluator.non_zero_polygon(kZeroAreaPolygon, suppress_warning=False) out, err = capfd.readouterr() assert round(result.area, 3) == 1.005 assert result.bounds == (0.95, 0.95, 11.05, 1.05) assert len(err) > 0
def test_match_detections_no_detections(): # TODO: is this the correct result? evaluator = ObjectAreaEvaluator() result = evaluator.match_detections(kGroundTruth, list()) assert result == (0., 0., (0., 0.), (0., 5.))
def test_match_detections(): evaluator = ObjectAreaEvaluator() result = evaluator.match_detections(kGroundTruth, kDetected) assert result == ([[], [1, 2], [3], [3], [4]], [[], [1], [1], [2, 3], [4], [], []])
def test_evaluate_no_detections(): evaluator = ObjectAreaEvaluator() result = evaluator.evaluate(kGroundTruth, list()) assert result == (0., 0., (0., 0.), (0., 5.))
def test_evaluate(): evaluator = ObjectAreaEvaluator() result = evaluator.evaluate(kGroundTruth, kDetected) assert result == (0.5714285714285714, 0.8, (4.0, 7.0), (4.0, 5.0))
def test_prune_and_polygon(): gt_poly, det_poly = ObjectAreaEvaluator.prune_and_polygon( kGroundTruth, kDetected) assert [p.length for p in gt_poly] == [18.0, 38.0, 20.0, 14.0, 10.0] assert [p.length for p in det_poly] == [18.0, 18.0, 28.0, 26.0, 10.0, 12.0, 14.0]
def test_non_zero_polygon_nonzero_area(): result = ObjectAreaEvaluator.non_zero_polygon(kNonZeroAreaPolygon) assert round(result.area, 3) == 100.0 assert result.bounds == (1.0, 1.0, 11.0, 11.0)
def test_prune_and_polygon(): gt_poly, det_poly = ObjectAreaEvaluator.prune_and_polygon(kGroundTruth, kDetected) assert [p.length for p in gt_poly] == [18.0, 38.0, 20.0, 14.0, 10.0] assert [p.length for p in det_poly] == [18.0, 18.0, 28.0, 26.0, 10.0, 12.0, 14.0]
def test_build_matrices(): gt_poly, det_poly = ObjectAreaEvaluator.prune_and_polygon(kGroundTruth, kDetected) gt_matrix, det_matrix = ObjectAreaEvaluator.build_matrices(gt_poly, det_poly) assert np.allclose(gt_matrix, kMatchMatrixGroundTruth) assert np.allclose(det_matrix, kMatchMatrixDetections)