def test__bbox_overlap(basic_bbox): # test bbox that does not overlap non_overlapping_bbox = _Bbox(left=200, top=10, right=300, bottom=1000) overlap = basic_bbox.get_overlap_bbox(non_overlapping_bbox) assert overlap is None # test bbox that does overlap overlapping_bbox = _Bbox(left=0, top=500, right=100, bottom=2000) overlap = basic_bbox.get_overlap_bbox(overlapping_bbox) assert overlap == _Bbox(left=0, top=500, right=100, bottom=1000)
def test_bboxes_iou(): # test bboxes which do not overlap basic_bbox = _Bbox(left=0, top=10, right=100, bottom=1000) non_overlapping_bbox = _Bbox(left=200, top=10, right=300, bottom=1000) assert bboxes_iou(basic_bbox, non_overlapping_bbox) == 0 # test bboxes which overlap overlapping_bbox = _Bbox(left=10, top=500, right=300, bottom=2000) assert bboxes_iou(basic_bbox, overlapping_bbox) == pytest.approx(0.092, rel=1e-2)
def od_sample_bboxes() -> List[_Bbox]: """ Returns the true bboxes from the `od_sample_im_anno` fixture. """ return [_Bbox(left=100, top=173, right=233, bottom=521)]
def test__bbox_is_valid(basic_bbox): assert basic_bbox.is_valid() is True assert _Bbox(left=0, top=0, right=0, bottom=0).is_valid() is False
def basic_bbox() -> "_Bbox": return _Bbox(left=0, top=10, right=100, bottom=1000)
def test__bbox_standardization(): non_standard_bbox_0 = _Bbox(left=100, top=1000, right=0, bottom=10) validate_bbox(non_standard_bbox_0)