import cv2
import numpy as np
frameWidth = 640
frameHeight = 480
cap = cv2.VideoCapture(0)
cap.set(3,frameWidth)
cap.set(4,frameHeight)
cap.set(10,150)
myColors=[[5,107,0,19,255,255],
[133,56,0,159,156.255],
[57,76,0,100,255,255]]
def findColors(img,myColors):
imgHSV = cv2.cvtColor(img,cv2.COLOR_BGR2HSV)
for color in myColors:
lower = np.array(color[0:3])
upper = np.array(color[3:6])
mask = cv2.inRange(imgHSV, lower, upper)
cv2.imshow(str(color[0]),mask)
while True:
success, img = cap.read()
findColors(img,myColors)
cv2.imshow("result", img)
if cv2.waitKey(1) & 0xFF == ord ('q'):
break
I have been trying to create a colour tracker which would go about tracing the colour from the camera and i have been stuck here awhile any help would be appreciated
error: (-209:Sizes of input arguments do not match) The upper boundary is neither an array of the same size and same type as src, nor a scalar in function 'cv::inRange'
Can someone help me here
there is a typo in your code.
[133,56,0,159,156.255],
use a ,
there, not a .
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments