I am trying to save the image modified by the trackbar. When I try to save it (using imwrite
), it only saves the image before it has been modified by the trackbar. Not shown in the following code, but I have tried using imwrite
in the foo
function which did not work. I also tried returning the image and the getTrackbarPos
from the foo
function, but both values were the unmodified inputs.
import cv2
def foo(val):
thresholdVal = cv2.getTrackbarPos('trackbar','window')
_, dst = cv2.threshold(image, thresholdVal, 255, cv2.THRESH_BINARY)
cv2.imshow('window',dst)
image = cv2.imread('img.jpg')
cv2.namedWindow('window')
cv2.createTrackbar('trackbar','window',0,255,foo)
foo(0)
cv2.waitKey(0)
cv2.destroyAllWindows
question from:https://stackoverflow.com/questions/65907325/how-to-save-an-image-modified-by-some-trackbar