# hsv_color_picker
"""
import cv2
import numpy as np
def nothing(x):
pass
cv2.namedWindow("frame")
cv2.createTrackbar("H","frame",0,179,nothing)
cv2.createTrackbar("S","frame",255,255,nothing)
cv2.createTrackbar("V","frame",255,255,nothing)
img_hsv=np.zeros((250,500,3),np.uint8)
while True:
h=cv2.getTrackbarPos("H","frame")
s=cv2.getTrackbarPos("S","frame")
v=cv2.getTrackbarPos("V","frame")
img_hsv[:]=(h,s,v)
img_bgr=cv2.cvtColor(img_hsv,cv2.COLOR_HSV2BGR)
cv2.imshow("frame",img_bgr)
key=cv2.waitKey(1)
if key==27:
break
cv2.destroyWindow()
"""
import cv2
cap=cv2.VideoCapture(1)
cap.set(cv2.CAP_PROP_FRAME_WIDTH,1280)
cap.set(cv2.CAP_PROP_FRAME_HEIGHT,720)
while True:
_,frame=cap.read()
hsv_frame=cv2.cvtColor(frame,cv2.COLOR_BGR2HSV)
height,width,_=frame.shape
cy,cx=height//2,width//2
# 获取画面中心点像素值
pixel_center=hsv_frame[cy,cx]
hue_value=pixel_center[0]
color="Undefined"
if 0