滑动轨迹栏作调色板
cv.createTrackbar(‘R’, ‘image’, 0, 255, nothing)
参数:哪个滑动轨迹栏,哪个窗口,最小值,最大值,回调函数
cv.getTrackbarPos(‘R’, ‘image’)
参数:轨迹栏名,窗口名文章来源:https://www.toymoban.com/news/detail-708764.html
import numpy as np
import cv2 as cv
def nothing(x):
pass
img = np.zeros((600, 512, 3), np.uint8)
cv.namedWindow('image', 0)
cv.createTrackbar('R', 'image', 0, 255, nothing)
cv.createTrackbar('G', 'image', 0, 255, nothing)
cv.createTrackbar('B', 'image', 0, 255, nothing)
switch = 'OFF : ON'
cv.createTrackbar(switch, 'image', 0, 1, nothing)
while(1):
cv.imshow('image', img)
k = cv.waitKey(1) & 0xFF
if k == 27:
break
r = cv.getTrackbarPos('R', 'image')
g = cv.getTrackbarPos('G', 'image')
b = cv.getTrackbarPos('B', 'image')
s = cv.getTrackbarPos(switch, 'image')
if s == 0:
img[:] = 0
else:
img[:] = [b, g, r] # *****************
cv.destroyAllWindows()
文章来源地址https://www.toymoban.com/news/detail-708764.html
到了这里,关于用滑动条做调色板---cv2.getTrackbarPos(),cv2.creatTrackbar()的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!