import numpy as np import pytest from hermes_vision.detect import Face, FaceDetector, merge, yunet_input_size @pytest.mark.parametrize('size,expected', [ ((1296, 972), (640, 480)), ((640, 480), (640, 480)), ((320, 240), (320, 256)), # small frames are not upscaled; 240/32 = 7.5 rounds to 8 ((1920, 1080), (640, 352)), ((10, 10), (32, 32)), ]) def test_yunet_input_size_is_a_multiple_of_32(size, expected): got = yunet_input_size(*size) assert got == expected and got[0] % 32 == 0 and got[1] % 32 == 0 def test_merge_drops_overlapping_boxes_and_keeps_distinct_ones(): a, b, c = Face(100, 100, 80, 80), Face(105, 98, 78, 82), Face(400, 100, 80, 80) assert merge([a, b, c]) == [a, c] def test_blank_image_has_no_faces(): det = FaceDetector(model_path='/nonexistent.onnx') # forces the Haar fallback assert det.backend == 'haar' assert det.detect(np.zeros((480, 640, 3), np.uint8)) == []