Python OpenCV – setTrackbarMin()
In this article, we will discuss how to set the minimum position of the trackbar. The minimum value of the track bar can be achieved using the function setTrackbarMin() from the OpenCV package in python. This function sets the minimum position of the specified trackbar in the specified window after creating the trackbar.
setTrackbarMin() function sets the minimum position of the track bar in the window. It does not return anything. This function 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.
Syntax: cv.setTrackbarMax(trackbarname, winname, maxval)
- trackbarname: Name of the trackbar
- winname: Name of the window that is the parent of trackbar
- maxval: New maximum position
In this example, we have created a window with a black image. Further, we create a trackbar using the createTrackbar() function and set the minimum value of trackbar using setTrackbarMin() function to 100. After that, we will create a loop for displaying an image and trackbar. So, whenever we move the trackbar position, the shades of black change.
In this example, we have created a window with a black image. Further, we create three trackbars of red, green, and blue color using the createTrackbar() function and set the minimum values of the trackbar using the setTrackbarMin() function to 50, 100, and 150. Later, we create a loop for displaying an image and trackbar. So, whenever we move the trackbar positions, the shades of red, green, and blue change.