Recognize circles of a given color

Hello, has anyone implemented a code to recognize circles of a certain color (for example Red)? He could put the code on me. Thank you

Hi, you could check the color at the circle center if it’s a filled circle, or check the pixels on the circle’s circumference if it’s empty.

For example:

# For filled circle:
r,g,b = img.get_pixel(c.x(), c.y())
if r > 200 and g < 25 and b < 25:
    print("red circle")

# For empty circle (you may want to average 5 pixels before and after cx+cr)
r,g,b = img.get_pixel(c.x() + c.r(), c.y())
if r > 200 and g < 25 and b < 25:
    print("red circle")

Mmm, I thought I answered this… Um, use find_circles combined with get_stats on the returned circle rect. This will find the circle and then return the color.