Reputation:
Using opencv, can a detection of a certain colour(Between a certain range of rgb values) be carried out in an image or a video frame?
Upvotes: 6
Views: 14775
Reputation: 52646
Yes, better convert the image to HSV and try the 'InRangeS' function. Here is an example to track two different colors at same time:
https://github.com/abidrahmank/OpenCV-Python/blob/master/Other_Examples/multi_color_two_object.py
Hope it helps.
Upvotes: 3
Reputation: 22245
You need to the define the treshold in RGB, and process the pixels in the image (hopefully not the whole image but a smaller region of interest, maybe a moving foreground shape) that fit to the deffinition. Something similar to what is discussed here.
I am understanding that you know the color(or colors) you want to detect a priori.
I hope this helps.
Upvotes: 3