feat: 拼接偵測加入左右排除邊距,box 預設排除右側多出的一欄
錯位模組畫面有 6x3 共 18 格,原本只能靠過渡門檻碰巧湊到 15 格且選錯格。stitcher.exclude_x 只篩選格子,box 設定為 [0, 240],可依感測器改寫;合成畫面測試與實機連續開啟 6 次全數成功。 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -166,3 +166,45 @@ def test_compound_eye_processor_calls_stitcher():
|
||||
def test_unknown_backend_raises():
|
||||
with pytest.raises(ValueError):
|
||||
get_blend_backend("torch")
|
||||
|
||||
|
||||
def _six_by_three_frame():
|
||||
"""A 1920x1080 frame showing 6x3 tiles: one column more than the 15 detected."""
|
||||
img = np.zeros((1080, 1920, 3), dtype=np.uint8)
|
||||
for cx in (160, 470, 790, 1110, 1430, 1750):
|
||||
for cy in (180, 520, 860):
|
||||
img[cy - 120:cy + 120, cx - 120:cx + 120] = 200
|
||||
return img
|
||||
|
||||
|
||||
def _detect(img, **kwargs):
|
||||
from orisys.stitch.boxes import detect_nonblack_regions
|
||||
|
||||
return detect_nonblack_regions(
|
||||
img, box_size=(250, 250), min_area_frac=0.01, max_area_frac=0.05,
|
||||
max_aspect_ratio=50, save_preview_path="", **kwargs,
|
||||
)
|
||||
|
||||
|
||||
def test_an_extra_tile_column_is_counted_without_an_exclusion():
|
||||
n_boxes, _boxes = _detect(_six_by_three_frame())
|
||||
assert n_boxes == 18
|
||||
|
||||
|
||||
@pytest.mark.parametrize("exclude_x", [(330, 0), (0, 330)])
|
||||
def test_exclude_x_masks_out_the_extra_column(exclude_x):
|
||||
n_boxes, boxes = _detect(_six_by_three_frame(), exclude_x=exclude_x)
|
||||
assert n_boxes == 15
|
||||
centres = sorted({(x0 + x1) // 2 for x0, _y0, x1, _y1 in boxes})
|
||||
assert (160 not in centres) == (exclude_x[0] > 0)
|
||||
assert (1750 not in centres) == (exclude_x[1] > 0)
|
||||
|
||||
|
||||
def test_the_shipped_right_margin_keeps_an_aligned_module():
|
||||
"""[0, 240] drops an extra edge column but not the outer column of a 5x3 module."""
|
||||
img = np.zeros((1080, 1920, 3), dtype=np.uint8)
|
||||
for cx in (324, 642, 960, 1278, 1596):
|
||||
for cy in (180, 520, 860):
|
||||
img[cy - 120:cy + 120, cx - 120:cx + 120] = 200
|
||||
assert _detect(img, exclude_x=(0, 240))[0] == 15
|
||||
assert _detect(_six_by_three_frame(), exclude_x=(0, 240))[0] == 15
|
||||
|
||||
Reference in New Issue
Block a user