Python OpenCV – setTrackbarPos() Function
setTrackbarPos() function sets the position of the specified trackbar in the specified window. It does not return anything. setTrackbarPos() takes three arguments. The first is for the trackbar name and the second one is the window name which is the parent of the trackbar and the third one is for the new value of the position that is to be set to the trackbar. It returns None.
cv.setTrackbarPos( trackbarname, winname, pos)
- trackbarname – Name of trackbar.
- winname – Name of the window that is the parent of the trackbar.
- pos – New position.
To create Track bars first import all the required libraries and create a window. Now create track bar(s) and add code to change or work as per their movement.
When we move the slider of any of the trackbar its corresponding getTrackbarPos() values changes and it returns the position of the specific slider. Through which we change the behavior accordingly.
Example: Using setTrackbarPos() function to change colors in a window
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning - Basic Level Course