How to create Trackbars which do not call any function? OpenCV 3.1 with Python 2.7

asked 2016-03-29 11:06:33 -0600

YaddyVirus gravatar image

Hi there!
I'm trying to threshold an image. I have used the cv2.createTrackbar function as-
cv2.createTrackbar('High H','image',0,179, None).
Now the last part is what I'm having trouble with. Further in my code, I use highH = cv2.getTrackbarPos('High H','image') to get my trackbar value and use it in the cv2.inRange function. So it becomes pretty obvious that I do not need to call a function as the last argument of the function. Now the problem is I can't seem to type in the function. I tried removing the last part, I got an error-

cv2.createTrackbar only works with 5 arguements. Only 4 given.
Hmm, okay seems like I can't skip a part.

Next I tried callback and nothing. I got this error:-
When used nothing:- NameError: name 'nothing' is not defined
When used callback:- NameError: name 'callback' is not defined

Okay after a while I tried using None. Got this error:- TypeError: on_change must be callable
So how do I use the cv2.createTrackbar function without calling a function?

Thanks!

edit retag flag offensive close merge delete

Comments

You need to pass a NULL pointer. I'm not sure the specifics in Python, but I think it's just NULL. The OpenCV function recognizes that as not wanting to do anything and just updates the value.

Tetragramm gravatar imageTetragramm ( 2016-03-29 20:24:31 -0600 )edit

I tried that. It didn't work. But I have solved my problem. I made an empty function which returns nothing, and the I called that. @Tetragramm

YaddyVirus gravatar imageYaddyVirus ( 2016-03-30 07:01:37 -0600 )edit