1.回调函数
def nothing(x):
pass
2.处理函数
def process(path):
img = cv2.imread(path)
img1 = img.copy()
gray = cv2.cvtColor(img1, cv2.COLOR_BGR2GRAY)
imgg = equalHist(gray)#equalHist为自定义函数
img2 = cv2.GaussianBlur(imgg, (25, 25), 0)
cv2.createTrackbar('threshold1', 'image', 0, 255, nothing)
cv2.createTrackbar('threshold2', 'image', 0, 255, nothing)
while (True):
threshold1 = cv2.getTrackbarPos('threshold1', 'image')
threshold2 = cv2.getTrackbarPos('threshold2', 'image')
img_output = cv2.Canny(img2, threshold1, threshold2)
cv2.imshow('image', img_output)
if cv2.waitKey(1) == ord(' '):#空格停止
break
cv2.destroyAllWindows()
拿到合适的值之后,可以更好地进行后续处理
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)