python 3.x tkinter, integrating frames from opencv cv2 into tkinter window
I understand now, if you too pull me up
I have to
- create a frame
- create a label inside of the frame
- take the camera's view and convert it into an image
- read the image and assigned to a variable
- create a new property for the label (image)
- assign the red image to the property
- configure the label to display the image
so clear now, so obvious
here is the code (include previous libraries)
from PIL import Image, ImageTk (add library)mGui = Tk()mGui.geometry('600x600+0+0')mGui.configure(background="Sky Blue")fframe = Frame(mGui, width=500, height=500)fframe.place(x=50, y=50)cap = cv2.VideoCapture(0)ret, frame = cap.read()v1 = Label(fframe, text="fchgvjvjhb")v1.place(x=0, y=10)v2 = Label(fframe, text="ajajajaja")v2.place(x=300, y=10)def dddd(): ret, frame = cap.read() img = Image.fromarray(frame) nimg = ImageTk.PhotoImage(image=img) v1.n_img = nimg v1.configure(image=nimg) gray = cv2.cvtColor(frame,cv2.COLOR_BGR2GRAY) gimg = Image.fromarray(gray) gnimg = ImageTk.PhotoImage(image=gimg) v2.ng_img = gnimg v2.configure(image=gnimg) mGui.after(10, dddd) dddd()mGui.mainloop()