-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathimporvedgraphicaltest.py
51 lines (40 loc) · 1.24 KB
/
imporvedgraphicaltest.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# -*- coding: utf-8 -*-
"""
Created on Sat Mar 11 14:13:05 2017
@author: Daniel
"""
#This is a application that when the button is pressed
#the current frame is uploaded to AWS to check if it is a authorized person
#This is the test for the integration of opencv into tkinter so buttons can be used
#import nessisary libraries
import cv2
import Tkinter as tk
from PIL import Image, ImageTk
def show_frame():
#width, height = 800, 600
root = tk.Tk()
lmain = tk.Label(root)
lmain.pack()
cap = cv2.VideoCapture(0)
def callback():
print "Authorize"
label = tk.Label(root, text = "Please, press the button to authorize.")
button = tk.Button(root, text="Authorize", command=callback)
label.pack(side=tk.RIGHT)
button.pack(side=tk.RIGHT)
while True:
ret_val, frame = cap.read()
frame = cv2.flip(frame, 1)
cv2image = cv2.cvtColor(frame, cv2.COLOR_BGR2RGBA)
img = Image.fromarray(cv2image)
imgtk = ImageTk.PhotoImage(image=img)
lmain.imgtk = imgtk
lmain.configure(image=imgtk)
lmain.after(10, show_frame)
#show_frame()
#Code to run app
def main():
show_frame()
root.mainloop()
if __name__ == '__main__':
main()