Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

is there a way to set trackbar position?

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