-
Notifications
You must be signed in to change notification settings - Fork 1
/
test7.py
34 lines (28 loc) · 852 Bytes
/
test7.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import tkinter as tk
from PIL import ImageTk, Image
import cv2
import threading
def camThread():
color = []
cap = cv2.VideoCapture(1)
panel = None
while True:
ret, color = cap.read()
if(color != []):
cv2.imshow("color", color)
image = cv2.cvtColor(color, cv2.COLOR_BGR2RGB)
image = Image.fromarray(image)
image = ImageTk.PhotoImage(image)
if panel is None:
panel = tk.Label(image=image)
panel.image = image
panel.pack(side="left")
else:
panel.configure(image=image)
panel.image = image
cv2.waitKey(1)
if __name__=='__main__' :
thread_img = threading.Thread(target=camThread, args=())
thread_img.start()
root = tk.Tk()
root.mainloop()