I was looking at this question:
How to detect blue color object using opencv
Yet after much trial and error, I still can't figure out how to detect blue objects.
Here is my code:
import cv2
import numpy as np
cam=cv2.VideoCapture(0)
n=0
while True:
print n
returnVal,frame=cam.read()
img=cv2.GaussianBlur(frame, (5,5), 0)
img=cv2.cvtColor(frame, cv2.COLOR_BGR2HSV)
blue_lower=np.array([150,150,0],np.uint8)
blue_upper=np.array([180,255,255],np.uint8)
blue=cv2.inRange(img,blue_lower,blue_upper)
cv2.imshow('img',blue)
n=n+1
key = cv2.waitKey(10) % 0x100
if key == 27: break #ESC
I can detect red objects by setting the following lines:
red_lower=np.array([0,150,0],np.uint8)
red_upper=np.array([10,255,255],np.uint8)
When I put a blue piece of paper in front of my webcam using the first code, it just shows up black.
Can someone please help me to convert RGB for blue colours into HSV?
Many thanks in advance,
blue_lower=np.array([100,150,0],np.uint8)blue_upper=np.array([120,255,255],np.uint8). Why is blue not between 150 and 180???