color_picker.py 文件源码

python
阅读 22 收藏 0 点赞 0 评论 0

项目:Opencv-Python-Examples- 作者: arijitx 项目源码 文件源码
def color_picker(rect):
    global img,img_gray2,hsv
    roi=img[rect[0][1]:rect[1][1],rect[0][0]:rect[1][0]]
    b,g,r,_=np.uint8(cv2.mean(roi))
    color=cv2.cvtColor(np.uint8([[[b,g,r]]]),cv2.COLOR_BGR2HSV)
    h= color[0][0][0]
    # define range of blue color in HSV
    lower = np.array([h-10,50,50])
    upper = np.array([h+10,255,255])

    # Threshold the HSV image to get only blue colors
    mask = cv2.inRange(hsv, lower, upper)

    # Bitwise-AND mask and original image
    res = cv2.bitwise_and(img,img, mask= mask)
    res2=cv2.bitwise_and(img_gray2,img_gray2, mask= cv2.bitwise_not(mask))
    return res+res2
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号