econsystems / opencv

Easy way to communicate with the camera using this OpenCV patch in c++
35 stars 17 forks source link

createTrackbar() does not work. #6

Open MainForm opened 3 years ago

MainForm commented 3 years ago

I want to make some trackbar by opencv. But, It doesn't work. Program just quit after call createTrackbar() function. So, I uninstalled this opencv version I download at this git. And, I reinstalled opencv of recent version. And, It worked.

here is my code.

from os import truncate import cv2 import numpy as np

frame = np.zeros((500,500,3),np.uint8)

WindowTitle = 'TrackBar' cv2.namedWindow(WindowTitle)

def trackbar_callback(color,value): frame[:,:,color] = value

cv2.createTrackbar('r',WindowTitle,0,255,lambda v: trackbar_callback(2,v))

cv2.createTrackbar('g',WindowTitle,0,255,lambda v: trackbar_callback(1,v))

cv2.createTrackbar('b',WindowTitle,0,255,lambda v: trackbar_callback(0,v))

while True:

cv2.imshow(WindowTitle,frame)

if cv2.waitKey(1) == 27:
    break

cv2.destroyAllWindows()