python - opencv - convert pixel from bgr to hsv

微笑、不失礼 提交于 2019-12-05 11:04:47

From the docs:

# Convert BGR to HSV
hsv = cv2.cvtColor(frame, cv2.COLOR_BGR2HSV)
# define range of blue color in HSV
lower_blue = np.array([110,50,50])
upper_blue = np.array([130,255,255])
# Threshold the HSV image to get only blue colors
mask = cv2.inRange(hsv, lower_blue, upper_blue)

You can just convert your whole img to hsv using the built in method:

hsv_img = cv2.cvtColor(img, cv2.COLOR_BGR2HSV)
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!