Add explicit detectors and optional auth

This commit is contained in:
2026-04-11 17:23:25 +02:00
parent 19a5ac16b7
commit 09119e8c0e
7 changed files with 189 additions and 65 deletions

View File

@@ -1,6 +1,6 @@
import numpy as np
from app.vision import BBox, crop_image, detect_salient_object, select_primary_bbox, square_bbox
from app.vision import BBox, crop_image, detect_animal, detect_subject, select_primary_bbox, square_bbox
def test_square_bbox_is_square_and_inside_bounds():
@@ -21,17 +21,25 @@ def test_crop_image_uses_bbox():
assert crop.shape[:2] == (20, 30)
def test_detect_salient_object_finds_rectangle():
def test_detect_subject_finds_rectangle():
image = np.zeros((100, 100, 3), dtype=np.uint8)
image[25:75, 30:80] = 255
bbox = detect_salient_object(image)
bbox = detect_subject(image)
assert bbox is not None
assert bbox.w >= 45
assert bbox.h >= 45
def test_select_primary_bbox_falls_back_when_detector_disabled():
def test_detect_animal_uses_contour_fallback():
image = np.zeros((100, 100, 3), dtype=np.uint8)
image[20:70, 15:85] = 255
bbox = detect_animal(image)
assert bbox is not None
assert bbox.w >= 50
def test_select_primary_bbox_defaults_to_subject():
image = np.zeros((100, 120, 3), dtype=np.uint8)
bbox, method = select_primary_bbox(image, detector="center")
bbox, method = select_primary_bbox(image)
assert method == "center_fallback"
assert bbox.w == bbox.h