could someone explain me why after modyfication of commented out code there is no camera view more? I get error message
" self.a = Image.fromarray(self.capture)#PIL 1.6# AttributeError: class Image has no attribute 'fromarray'"
from x.update_video method. Commented code is from topic OpenCV (cv2 in Python) VideoCapture not releasing camera after deletion I am very new to Tkinter and found no help in tutorials. I suppose it is due to frame is packed as well as canvas. But there must be any solution...
class App:
def __init__(self, master,cam):
## root = tk.Tk()
## videoframe = tk.LabelFrame(root,text='Captured video')
## videoframe.grid(column=0,row=0,columnspan=1,rowspan=1,padx=5, pady=5, ipadx=5, ipady=5)
## canvas = tk.Canvas(videoframe, width=640,height=480)
## canvas.grid(column=0,row=0)
## cam = cv2.VideoCapture(2)
## x = vid(cam,root,canvas)
## root.after(0,x.update_video)
## button = tk.Button(text='Quit',master=videoframe,command=root.destroy)
## button.grid(column=0,row=1)
## root.mainloop()
## del cam
frame = LabelFrame(master,text='Captured video')
frame.pack()
canvas = Canvas(frame, width=640,height=480)
canvas.pack(side=TOP)
x = vid(cam,master,canvas)
master.after(0,x.update_video)
self.button = Button(frame, text="QUIT", fg="red", command=master.destroy)
self.button.pack(side=LEFT)
self.hi_there = Button(frame, text="Hello", command=self.say_hi)
self.hi_there.pack(side=LEFT)
def say_hi(self):
print "hi there, everyone!"
root = Tk()
cam = cv2.VideoCapture(0)
app = App(root,cam)
root.mainloop()
del cam