Python OpenCV - getTrackbarPos() Function Last Updated : 03 Jan, 2023 Comments Improve Suggest changes Like Article Like Report getTrackbarPos() is Function in Python OpenCV that returns the current position of the specified trackbar. It takes two arguments. The first is for the trackbar name and the second one is the window name which is the parent of the trackbar. Returns the trackbar position. Syntax : cv.getTrackbarPos(trackbarname, winname) Parameters : trackbarname: Name of trackbarwinname: Name of the window that is the parent of the trackbar. Return : Current position of the specified trackbar Note: [Only for Qt Backend] Here, If the trackbar is attached to the control panel then winname can be empty or Null. Below is the implementation: Python3 # Demo Trackbar # importing cv2 and numpy import cv2 import numpy def nothing(x): pass # Creating a window with black image img = numpy.zeros((300, 512, 3), numpy.uint8) cv2.namedWindow('image') # creating trackbars for red color change cv2.createTrackbar('R', 'image', 0, 255, nothing) # creating trackbars for Green color change cv2.createTrackbar('G', 'image', 0, 255, nothing) # creating trackbars for Blue color change cv2.createTrackbar('B', 'image', 0, 255, nothing) while(True): # show image cv2.imshow('image', img) # for button pressing and changing k = cv2.waitKey(1) & 0xFF if k == 27: break # get current positions of all Three trackbars r = cv2.getTrackbarPos('R', 'image') g = cv2.getTrackbarPos('G', 'image') b = cv2.getTrackbarPos('B', 'image') # display color mixture img[:] = [b, g, r] # close the window cv2.destroyAllWindows() Output: When we move the slider of any of R, G, or B its corresponding getTrackbarPos() values changes and it returns the position of the specific slider. Through which we change the color of the below box. You can see in the code we pass to the argument to getTrackbarPos(). Let's take r for example, we pass 'R' and 'image' to function. Here 'R' is the Trackbar name that we created and 'image' is the name of the window that opens when we run code. Basically, it is the parent window of the trackbar. This returns the position of the slider as an integer value and we save it in r. We create color box with this return value 'r', 'g' and 'b'. Comment More infoAdvertise with us Next Article Python OpenCV - getTrackbarPos() Function R rushi_javiya Follow Improve Article Tags : Python OpenCV Python-OpenCV Practice Tags : python Similar Reads Essential OpenCV Functions to Get Started into Computer Vision Computer vision is a process by which we can understand the images and videos how they are stored and how we can manipulate and retrieve data from them. Computer Vision is the base or mostly used for Artificial Intelligence. Computer-Vision is playing a major role in self-driving cars, robotics as w 7 min read cv2.imread() method - Python OpenCV OpenCV-Python is a Python library used to solve computer vision tasks. cv2.imread() method loads an image from the specified file. If the image cannot be read because of missing file, improper permissions or an unsupported/invalid format then it returns an empty matrix.Example:Pythonimport cv2 image 2 min read Python OpenCV | cv2.imshow() method OpenCV-Python is a library of Python bindings designed to solve computer vision problems. cv2.imshow() method is used to display an image in a window. The window automatically fits the image size. Syntax: cv2.imshow(window_name, image)Parameters: window_name: A string representing the name of the wi 3 min read Python OpenCV | cv2.cvtColor() method OpenCV-Python is a library of Python bindings designed to solve computer vision problems. cv2.cvtColor() method is used to convert an image from one color space to another. There are more than 150 color-space conversion methods available in OpenCV. We will use some of color space conversion codes be 4 min read Python OpenCV | cv2.imwrite() method OpenCV-Python is a library of Python bindings designed to solve computer vision problems. cv2.imwrite() method is used to save an image to any storage device. This will save the image according to the specified format in current working directory. Syntax: cv2.imwrite(filename, image) Parameters:file 2 min read Python OpenCV | cv2.rectangle() method OpenCV-Python is a library of Python bindings designed to solve computer vision problems. cv2.rectangle() method is used to draw a rectangle on any image. Syntax: cv2.rectangle(image, start_point, end_point, color, thickness) Parameters:image: It is the image on which rectangle is to be drawn. start 4 min read cv2.circle() method OpenCV-Python is a library of Python bindings designed to solve computer vision problems. cv2.circle() method is used to draw a circle on any image. We use this image:Example:Pythonimport cv2 path = r'C:\Users\user\Desktop\geeks14.png' src = cv2.imread(path) cv2.circle(src, center=(100, 100), radius 2 min read Python OpenCV | cv2.line() method OpenCV-Python is a library of Python bindings designed to solve computer vision problems. cv2.line() method is used to draw a line on any image.Syntax:cv2.line(image, start_point, end_point, color, thickness) Parameters: image: It is the image on which line is to be drawn. start_point: It is the sta 3 min read Python OpenCV | cv2.putText() method OpenCV-Python is a library of Python bindings designed to solve computer vision problems. cv2.putText() method is used to draw a text string on any image. Syntax: cv2.putText(image, text, org, font, fontScale, color[, thickness[, lineType[, bottomLeftOrigin]]]) Parameters:image: It is the image on w 5 min read Line detection in python with OpenCV | Houghline method The Hough Transform is a method that is used in image processing to detect any shape, if that shape can be represented in mathematical form. It can detect the shape even if it is broken or distorted a little bit.We will see how Hough transform works for line detection using the HoughLine transform m 6 min read Like