Color detection opencv

自闭症网瘾萝莉.ら 提交于 2019-12-21 04:52:28

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!