Hello all, I am currently finding a solution to my problem very hard to come by what I want to do is create a trackbar with 10 settings corresponding to 0-255 and use this trackbar to carry out image thresholding.
I have tried all sorts of approaches and none have worked, I will show my code below.
import cv2
def bar(x):
pass
img = cv2.imread("messi5.png", cv2.IMREAD_GRAYSCALE)##Reads image from area in grayscale
cv2.namedWindow("Image")##Names the window with the trackbar "image"
cv2.createTrackbar("R", "Image", 255, 10, bar)##Creates trackbar with values 0-10
while True:##Loop for getting trackbar position and processing it
R = cv2.getTrackbarPos('R','Image')
r=2*R
value_threshold = cv2.getTrackbarPos("R", "Image") == 199 ((199//25.5) +1) * 25,5 == 204) ##Gets trackbar position
_, bar = cv2.threshold(img, value_threshold, 255,r, cv2.THRESH_BINARY)##Applies threshold
##Shows images in window
##cv2.imshow("Image", img)
cv2.imshow("Image", bar)
key = cv2.waitKey(10)
if key == 27:##If escape is pressed break
break
cv2.destroyAllWindows()