Rotation image distante
This commit is contained in:
1 parent
ec155d775f
commit
5b8518c19c
10 files changed
+130
-1
No files matched your search
@@ -719,6 +719,34 @@ def test_import_remote_last_photo(tmp_path, camera):
|
||||
assert camera.calls[-1] == "/old"
|
||||
|
||||
|
||||
def test_rotate_photo():
|
||||
from PIL import Image
|
||||
image = Image.new("RGB", (4, 2), (0, 0, 0))
|
||||
image.putpixel((0, 0), (255, 0, 0)) # coin haut gauche marque
|
||||
assert vision.rotate_photo(image, 0) is image
|
||||
turned = vision.rotate_photo(image, 90) # sens horaire
|
||||
assert turned.size == (2, 4) and turned.getpixel((1, 0)) == (255, 0, 0)
|
||||
turned = vision.rotate_photo(image, 180)
|
||||
assert turned.size == (4, 2) and turned.getpixel((3, 1)) == (255, 0, 0)
|
||||
turned = vision.rotate_photo(image, 270)
|
||||
assert turned.size == (2, 4) and turned.getpixel((0, 3)) == (255, 0, 0)
|
||||
with pytest.raises(ValueError):
|
||||
vision.rotate_photo(image, 45)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("rotation", [90, 180, 270])
|
||||
def test_import_remote_rotated(tmp_path, camera, capsys, rotation):
|
||||
# La photo tournee reste calibree : les reperes donnent l'orientation.
|
||||
svg = run(tmp_path, "BoardPhotoImport", "board_photo_import", EMPTY_MM,
|
||||
"--photo_source=remote", "--remote_host=127.0.0.1",
|
||||
"--remote_port={}".format(camera.port), "--remote_endpoint=old",
|
||||
"--remote_rotation={}".format(rotation))
|
||||
width, height = syn.PHOTO_SIZE
|
||||
size = (height, width) if rotation in (90, 270) else (width, height)
|
||||
assert "({} x {} px)".format(*size) in capsys.readouterr().err
|
||||
assert_holes_match(outline_rings(svg)[1:])
|
||||
|
||||
|
||||
def test_import_remote_errors(tmp_path, camera, capsys):
|
||||
port = camera.port
|
||||
run(tmp_path, "BoardPhotoImport", "board_photo_import", EMPTY_MM,
|
||||
|
||||
Reference in new issue
Block a user