我如何要求在跟踪栏窗口上显示栏的范围(最大值,最小值)和当前指向值?这是使用跟踪栏的示例。

# trackbar
import cv2
import numpy as np

def nothing(x):
    pass

img = np.zeros((300,512,3), np.uint8)
cv2.namedWindow('image')

# Create trackbars

cv2.createTrackbar('R', 'image', 255, 255, nothing)
cv2.createTrackbar('G', 'image', 0, 255, nothing)
cv2.createTrackbar('B', 'image', 0, 255, nothing)

# Create switch for on/off

switch = '0: OFF \n1: ON'
cv2.createTrackbar(switch, 'image', 0, 1, nothing)

while(1):
    cv2.imshow('image',img)
    k = cv2.waitKey(1) & 0xFF
    if k == 27:   # 27 is Escape
        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]

cv2.destroyAllWindows()

哪个不显示值:
python - OpenCV跟踪栏,如何在跟踪栏窗口上显示最大值,最小值和当前值-LMLPHP

最佳答案

无法指示与 pos=0 不同的最小值,但由于轨迹栏没有刻度标签,有时将第一个刻度重新解释为 1 (pos+1) 很有用

关于python - OpenCV跟踪栏,如何在跟踪栏窗口上显示最大值,最小值和当前值,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/32314087/

10-12 21:13