小编use*_*024的帖子

OpenCV:src不是数字元组

我用python编写了一个关于颜色检测的程序.但是'Erode'句子总是出现错误.这是我的计划的一部分.谢谢.

# Convert the image to a Numpy array since most cv2 functions
# require Numpy arrays.
frame = np.array(frame, dtype=np.uint8)

threshold = 0.05
#blur the image
frame=cv2.blur(frame, (5,5))
#Convert from BGR to HSV
hsv = cv2.cvtColor(frame, cv2.COLOR_BGR2HSV)
#split into 3
h, s, v= cv2.split(hsv)
#red color
s = cv2.threshold(h, 15, 1, cv2.THRESH_BINARY_INV)#1-15,x>15 y=0
h = cv2.threshold(h, 245, 1, cv2.THRESH_BINARY)#245-255 x>245 y=1
h = h + s
kernel = cv2.getStructuringElement(cv2.MORPH_RECT,(3, 3)) 
h = cv2.erode(h, kernel)
v = cv2.sumElems(h)
Run Code Online (Sandbox Code Playgroud)

python opencv numerical

9
推荐指数
1
解决办法
2万
查看次数

标签 统计

numerical ×1

opencv ×1

python ×1