OpenCV Android Green Color Detection

我们两清 提交于 2019-11-26 22:55:50
Miki

Green color is HSV space has H = 120 and it's in range [0, 360].

OpenCV halves the H values to fit the range [0,255], so H value instead of being in range [0, 360], is in range [0, 180]. S and V are still in range [0, 255].

As a consequence, the value of H for green is 60 = 120 / 2.

You upper and lower bound should be:

// sensitivity is a int, typically set to 15 - 20 
[60 - sensitivity, 100, 100]
[60 + sensitivity, 255, 255]

UPDATE

Since your image is quite dark, you need to use a lower bound for V. With these values:

sensitivity = 15;
[60 - sensitivity, 100, 50]  // lower bound
[60 + sensitivity, 255, 255] // upper bound

the resulting mask would be like:

You can refer to this answer for the details.

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