I am having a little trouble getting find_rects to find my squares.
Does find)rects find all rects including children rects insode larger rects or once it finds a large rect then it stops looking for children rects inside the larger 1.
Also what does the threshold arg for find_rects do??
Here’s a video showing my problem - YouTube
And this is the code that was running to make the video
import sensor, image, time
sensor.reset()
sensor.set_pixformat(sensor.RGB565) # grayscale is faster (160x120 max on OpenMV-M7)
sensor.set_framesize(sensor.QQVGA)
sensor.skip_frames(time = 2000)
clock = time.clock()
green_threshold = (7, 52, -128, -7, -128, 127)
white_threshold = (57, 83, -30, 85, -27, 48)
yellow_threshold = (46, 82, -30, 31, 28, 67)
blue_threshold = (4, 33, -37, 29, -59, -5)
red_threshold = (7, 49, 12, 56, 2, 57)
while True:
clock.tick()
img = sensor.snapshot()
blue_fb = img.binary([blue_threshold], to_bitmap=True, copy=True)
blue_fb.erode(1)
white_fb = img.binary([white_threshold], to_bitmap=True, copy=True)
white_fb.erode(1)
green_fb = img.binary([green_threshold], to_bitmap=True, copy=True)
green_fb.erode(1)
yellow_fb = img.binary([yellow_threshold], to_bitmap=True, copy=True)
yellow_fb.erode(1)
red_fb = img.binary([red_threshold], to_bitmap=True, copy=True)
red_fb.erode(1)
yellow_fb.b_or(green_fb).b_or(white_fb).b_or(blue_fb).b_or(red_fb)
for r in yellow_fb.find_rects(threshold = 1000):
img.draw_circle(r.x()+r.w()//2, r.y()+r.h()//2, r.w()//2, color = (0, 255, 0))
print(yellow_fb.compressed_for_ide(), end="")
print("FPS %f" % clock.fps())