openmv/scripts/unittest/tests/transpose.py
iabdalkader 4b1837f72e scripts: Update unit tests.
Co-authored-by: Kwabena W Agyeman <kwagyeman@users.noreply.github.com>
Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
2025-10-18 17:14:36 +02:00

20 lines
503 B
Python

def unittest(data_path, temp_path):
import image
# Create non-square test image
img = image.Image(60, 40, image.GRAYSCALE)
# Fill with pattern
for y in range(40):
for x in range(60):
img.set_pixel(x, y, (x + y) % 256)
# Transpose image (swap width and height)
img_t = img.copy(x_scale=1.0, y_scale=1.0, hint=image.TRANSPOSE)
# Verify dimensions are swapped
if img_t.width() != 40 or img_t.height() != 60:
return False
return True