Ask Your Question
1

is there a way to set trackbar position?

asked 2016-09-07 08:41:07 -0600

j0h gravatar image

I have a program, with six trackbars that helps me find the range of colours I can use to detect an object. There are sets of sliders, and the low values, should never exceed the high values, or the output is rendered useless.

I can adjust the trackbars manually, to set the high values as always greater than the low value, but its a little tedious. I would like to have a function update the position of the high trackbar, if the value on the low trackbar exceeds it.

# create track bars
cv2.createTrackbar('B-low','image',0,255,nothing)
cv2.createTrackbar('B-high','image',255,255,nothing)

while (1):
    bl = cv2.getTrackbarPos('B-low','image')
    bh = cv2.getTrackbarPos('B-high','image')
    if bh < bl:
        print(bl)
        bh == cv2.getTrackbarPos('B-high','image') + 1

I dont see an option for SetTrackBar position in the user interface documentation.

If anyone has an idea how I might do this, I'd be very interested. This is python, But I would be interested in C++ as well.

Full source: http://pastebin.com/7JHJsFxf

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
2

answered 2016-09-07 09:22:04 -0600

berak gravatar image

it's well hidden, but cv2 has setTrackbarPos() :

>>> import cv2
>>> help(cv2.setTrackbarPos) Help on built-in function setTrackbarPos:

setTrackbarPos(...)
    setTrackbarPos(trackbarname, winname, pos) -> None
edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2016-09-07 08:41:07 -0600

Seen: 13,835 times

Last updated: Sep 07 '16