mirror of
https://github.com/openmv/openmv.git
synced 2025-11-04 14:49:50 +08:00
Co-authored-by: Kwabena W Agyeman <kwagyeman@users.noreply.github.com> Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
37 lines
853 B
Python
37 lines
853 B
Python
def unittest(data_path, temp_path):
|
|
import image
|
|
import os
|
|
|
|
# Create test image
|
|
img = image.Image(60, 60, image.RGB565)
|
|
|
|
# Fill with pattern
|
|
for y in range(60):
|
|
for x in range(60):
|
|
color = ((x * 8) << 8) | ((y * 4) << 3) | ((x + y) >> 3)
|
|
img.set_pixel(x, y, color)
|
|
|
|
# Test BMP save/load
|
|
bmp_path = temp_path + "/test_image.bmp"
|
|
img.save(bmp_path)
|
|
|
|
img_loaded = image.Image(bmp_path)
|
|
if img_loaded.width() != 60 or img_loaded.height() != 60:
|
|
return False
|
|
|
|
# Cleanup
|
|
os.remove(bmp_path)
|
|
|
|
# Test PPM save/load
|
|
ppm_path = temp_path + "/test_image.ppm"
|
|
img.save(ppm_path)
|
|
|
|
img_loaded2 = image.Image(ppm_path)
|
|
if img_loaded2.width() != 60 or img_loaded2.height() != 60:
|
|
return False
|
|
|
|
# Cleanup
|
|
os.remove(ppm_path)
|
|
|
|
return True
|