-
Notifications
You must be signed in to change notification settings - Fork 1
/
test_cam.py
78 lines (62 loc) · 2.2 KB
/
test_cam.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
import cv2
from Plots import ContinuousPlots
# from tkinter import *
from tkinter import ttk
import tkinter as tk
import matplotlib.pyplot as plt
def call_video():
"""
Call the vidoe function from ContinousPlots class in the GUI
:return: None
"""
cp = ContinuousPlots()
double = cp.continuos_plots()
plt.imshow(double)
plt.show()
def upload_from_device():
"""
Call the upload_and_get_mask function from ContinousPlots class in the GUI
:return: None
"""
# Plot mask from upload
dp = ContinuousPlots()
double = dp.upload_and_get_mask()
plt.imshow(double)
plt.show()
def take_a_picture():
"""
Call the take_a_picture_and_get_mask function from ContinousPlots class in the GUI
:return: None
"""
ep = ContinuousPlots()
double = ep.take_a_picture_and_get_mask()
plt.imshow(double)
plt.show()
def print_camera_ids():
"""
Display the ID of cameras available in the device
:return: None
"""
cams_test = 500
for i in range(0, cams_test):
cap = cv2.VideoCapture(i)
test, frame = cap.read()
if test:
print(" &&& =============================================================== &&& \n")
print("i : " + str(i) + " /// result: " + str(test))
print(" &&& =============================================================== &&& \n")
parent = tk.Tk()
my_boolean_var = tk.BooleanVar()
parent.geometry("500x300")
parent.title('Choose One : 1.Video 2.Upload from device 3. Take Picture 4.Camera Test' )
label = ttk.Label(parent, text= 'Choose One :\n\n1. Video\n\n2. Upload from device '
'\n\n3. Take Picture\n\n4. Camera Test').place(x = 0,y = 0)
video_checkbutton = ttk.Button(parent,
text= "Take a Video", command=call_video).pack(padx=10, pady=10)
upload_checkbutton = ttk.Button(parent,
text= "Upload from device", command= upload_from_device).pack(padx=10, pady=10)
picture_checkbutton = ttk.Button(parent,
text= "Take picture from Camera", command=take_a_picture).pack(padx=10, pady=10)
cam_test_checkbutton = ttk.Button(parent,
text= "Print camera Ids", command=print_camera_ids).pack(padx=10, pady=10)
parent.mainloop()