25 lines
843 B
Python
25 lines
843 B
Python
from botty_next.vision.fixtures import load_screenshot, load_template
|
|
from botty_next.vision.template_matching import match_template, save_match_debug
|
|
|
|
|
|
def test_template_match_finds_sample_marker() -> None:
|
|
image = load_screenshot("sample_scene.ppm")
|
|
template = load_template("sample_marker.ppm")
|
|
|
|
result = match_template(image, template, threshold=0.99)
|
|
|
|
assert result.passed is True
|
|
assert result.confidence >= 0.99
|
|
assert result.bbox == (3, 2, 3, 3)
|
|
assert "image_shape" in result.debug
|
|
|
|
|
|
def test_template_match_can_save_debug_image(tmp_path) -> None:
|
|
image = load_screenshot("sample_scene.ppm")
|
|
template = load_template("sample_marker.ppm")
|
|
result = match_template(image, template, threshold=0.99)
|
|
|
|
output = save_match_debug(image, result, tmp_path / "marked.png")
|
|
|
|
assert output.exists()
|