问题
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?
回答1:
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.
回答2:
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.
回答3:
Yes - but it's easier in HSV color space. Tutorials here
来源:https://stackoverflow.com/questions/8884972/color-detection-opencv