from fam_edge.frame_service import _bbox_to_pixels def test_bbox_to_pixels_basic(): # [ymin,xmin,ymax,xmax] 0-1000 归一化 -> 像素 (x1,y1,x2,y2) # 实测样本:Gemini 对 440x248 帧返回 [0, 690, 203, 725], # 对应画面右上角门厅处的一个人(今天用真实截图验证过)。 x1, y1, x2, y2 = _bbox_to_pixels([0, 690, 203, 725], 440, 248) assert x1 == int(690 / 1000 * 440) assert y1 == 0 assert x2 == int(725 / 1000 * 440) assert y2 == int(203 / 1000 * 248) def test_bbox_to_pixels_full_frame(): x1, y1, x2, y2 = _bbox_to_pixels([0, 0, 1000, 1000], 400, 300) assert (x1, y1, x2, y2) == (0, 0, 400, 300) def test_bbox_to_pixels_zero_area(): x1, y1, x2, y2 = _bbox_to_pixels([500, 500, 500, 500], 400, 300) assert (x1, y1) == (x2, y2)