Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

createTrackbar() does not work. #6

Open
MainForm opened this issue Jan 11, 2021 · 0 comments
Open

createTrackbar() does not work. #6

MainForm opened this issue Jan 11, 2021 · 0 comments

Comments

@MainForm
Copy link

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()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant