This forum is disabled, please visit https://forum.opencv.org

1 | initial version |

imho, your ranges are a bit off. it will definitely get better, if you add some pixel-testing code to your prog to test the actual hsv values, like:

def onmouse(k,x,y,s,p): global hsv if k==1: # left mouse, print pixel at x,y print hsv[y,x]

cv2.namedWindow("hsv") cv2.setMouseCallback("hsv",onmouse); cv2.imshow('hsv',hsv)

using your image above i get something like:

[ 83 218 237]

then, you can adjust your ranges, maybe to:

lower_green = np.array([75,200,200]) upper_green = np.array([85,255,255])

and get a beautiful mask:

2 | No.2 Revision |

imho, your ranges are a bit off. it will definitely get better, if you add some pixel-testing code to your prog to test the actual hsv values, like:

```
def onmouse(k,x,y,s,p):
global hsv
if k==1: # left mouse, print pixel at x,y
print
```~~hsv[y,x]~~hsv[y,x]
~~ ~~cv2.namedWindow("hsv")
cv2.setMouseCallback("hsv",onmouse);
~~cv2.imshow('hsv',hsv)~~

cv2.imshow('hsv',hsv)

using your image above i get something like:

[ ~~83 ~~81 218 237]

then, you can adjust your ranges, maybe to:

```
lower_green = np.array([75,200,200])
upper_green =
```~~np.array([85,255,255])~~np.array([85,255,255])

and get a beautiful mask:

Copyright OpenCV foundation, 2012-2018. Content on this site is licensed under a Creative Commons Attribution Share Alike 3.0 license.