openmv/scripts/unittest/tests/selective_search.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

24 lines
722 B
Python

def unittest(data_path, temp_path):
import image
# Create test image with regions
img = image.Image(64, 64, image.RGB565)
# Create distinct regions
for y in range(64):
for x in range(64):
if x < 32 and y < 32:
color = 0xF800 # Red
elif x >= 32 and y < 32:
color = 0x07E0 # Green
elif x < 32 and y >= 32:
color = 0x001F # Blue
else:
color = 0xFFFF # White
img.set_pixel(x, y, color)
# Perform selective search segmentation
regions = img.selective_search(threshold=200, min_size=10)
return regions[0] == (0, 0, 63, 31) and regions[1] == (0, 0, 63, 63)