使用GUI进行cv2遮罩的部分代码,图像处理部分将从滑块获取值。这里的问题是,每当我移动滑块时,我都无法打印比例的名称和值。 OOP的新手,在这里呆了好几天。
from tkinter import *
master = Tk()
class makeObj:
def __init__(self, row, maxVal, name):
name=Label(master, text=str(name), fg="black")
name.grid(row=row)
name=Scale(master, from_=0, to=maxVal, length=500, orient=HORIZONTAL,command=self.read)
name.grid(row=row, column=1)
def read(name):
print(str(name)+' '+name.get)
makeObj(0,179,"hmax")
makeObj(1,179,"hmin")
makeObj(2,255,"smax")
makeObj(3,255,"smin")
makeObj(4,255,"vmax")
makeObj(5,255,"vmin")
mainloop()
错误:
Exception in Tkinter callback
Traceback (most recent call last):
File "C:\Program Files\Python\Python36\lib\tkinter\__init__.py", line 1702, in __call__
return self.func(*args)
TypeError: read() takes 1 positional argument but 2 were given