鼠标事件
events = [i for i in dir(cv2) if 'EVENT' in i]
跟踪条##
跟踪条
cv2.createTrackbar()
第一个参数:跟踪条的名字;
第二个参数:跟踪条将要绑定到那个windows窗口;
第三个参数:默认值;
第四个参数:最大值;
第五个参数:回调函数。
import cv2
import numpy as np
def nothing(x):
pass
# 创建
img=cv2.imread('./tupian/you.jpg')
cv2.namedWindow('image')
cv2.createTrackbar('R','image',0,255,nothing)
cv2.createTrackbar('G','image',0,255,nothing)
cv2.createTrackbar('B','image',0,255,nothing)
switch='0 : OFF \n 1: ON'
cv2.createTrackbar(switch,'image',0,1,nothing)
while(1):
cv2.imshow('image',img)
k=cv2.waitKey(1)& 0xFF
if k==27:
break
r=cv2.getTrackbarPos('R','image')
g=cv2.getTrackbarPos('G','image')
b=cv2.getTrackbarPos('B','image')
s=cv2.getTrackbarPos(switch,'image')
if s==0:
img[:]=0
else:
img[:]=[b,g,r]
http://opencv-python-tutroals.readthedocs.io/en/latest/py_tutorials/py_gui/py_mouse_handling/py_mouse_handling.html#mouse-handling
网友评论