Skip to content

createTrackbar() does not work. #6

Open
@MainForm

Description

@MainForm

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions