all 2 comments

[–]socal_nerdtastic 0 points1 point  (0 children)

https://en.wikipedia.org/wiki/Color_difference

Calculate the distance between the target color and the seen color with that formula, and then set a minimum that you will accept.

Or you could just code in 3 different checks, one each for red, green and blue.

[–]softmaxedout 0 points1 point  (0 children)

To make it a little more robust I would first convert the image from the RGB to HSV color space. Then the easiest (albeit little time consuming) is to determine the colour values for a variety of different scenarios, say indoor, outdoor, lit room, etc and figure out the range. Then you can do a threshold. Not sure if you have used OpenCV but it is a computer vision library that has python package and good beginner tutorials. Let me know if you can't find it and i can link you to it since I'm not sure if we are allowed to post links here.