Trackbars – OpenCV 3.4 with python 3 Tutorial 8
Source code:
[python]
import cv2
import numpy as np
def nothing(x):
pass
cap = cv2.VideoCapture(0)
cv2.namedWindow("frame")
cv2.createTrackbar("test", "frame", 50, 500, nothing)
cv2.createTrackbar("color/gray", "frame", 0, 1, nothing)
while True:
_, frame = cap.read()
test = cv2.getTrackbarPos("test", "frame")
font = cv2.FONT_HERSHEY_COMPLEX
cv2.putText(frame, str(test), (50, 150), font, 4, (0, 0, 255))
s = cv2.getTrackbarPos("color/gray", "frame")
if s == 0:
pass
else:
frame = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
cv2.imshow("frame", frame)
key = cv2.waitKey(1)
if key == 27:
break
cap.release()
cv2.destroyAllWindows()
[/python]

Hi there, I’m the founder of Pysource.
I’m a Computer Vision Consultant, developer and Course instructor.
I help Companies and Freelancers to easily and efficiently build Computer Vision Software.

Learn to build Computer Vision Software easily and efficiently.
This is a FREE Workshop where I'm going to break down the 4 steps that are necessary to build software to detect and track any object.
Sign UP for FREE