move_detect/tests/test_models.py

21 lines
659 B
Python

from edge.models import Keypoint, BBox, Person, L_SHOULDER, R_HIP, CORE_JOINTS
def test_bbox_derived_properties():
b = BBox(10, 20, 30, 80)
assert b.width == 20
assert b.height == 60
assert b.aspect == 20 / 60
assert b.cx == 20 and b.cy == 50
def test_bbox_zero_height_aspect_is_zero():
assert BBox(0, 0, 10, 0).aspect == 0.0
def test_person_holds_17_keypoints():
kps = [Keypoint(0, 0, 0.9) for _ in range(17)]
p = Person(BBox(0, 0, 1, 1), kps)
assert len(p.keypoints) == 17
assert p.keypoints[L_SHOULDER].conf == 0.9
def test_coco_index_constants():
assert CORE_JOINTS == (5, 6, 11, 12)
assert R_HIP == 12