问题描述
import cv2
import numpy as np
cap = cv2.VideoCapture(0)
while(1):
# Take each frame
_,frame = cap.read()
# Convert BGR to HSV
hsv = cv2.cvtColor(frame,cv2.COLOR_BGR2HSV)
#Now define range of color.
l = np.array([0,30,60])#lower range.
u = np.array([20,150,255])#upper range.
#threshold the image to get only skin color
mask = cv2.inRange(hsv,l,u)
#bitwise and the original image and mask
obj_img=cv2.bitwise_and(frame,frame,mask = mask)
cv2.imshow('frame',frame)
cv2.imshow('mask',mask)
cv2.imshow('res',res)
k = cv2.waitKey(5) & 0xFF
if k == 27:
break
cv2.destroyAllWindows()
cap.release()
这是仅提取肤色的代码,如果我想提取其他颜色,我该怎么办? 我想知道如何在同一张图片上使用多个按位。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)