Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
F
Face-Clock-Edge
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
YONG-LIN SU
Face-Clock-Edge
Commits
93f486df
Commit
93f486df
authored
Jul 03, 2019
by
Bruce
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
change api select by id
parent
7bce9d89
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
93 additions
and
70 deletions
+93
-70
Face-Clock-API.py
Face-Clock-API.py
+51
-40
Face-Clock-Insert-API.py
Face-Clock-Insert-API.py
+42
-30
No files found.
Face-Clock-API.py
View file @
93f486df
#!/usr/bin/env python
#!/usr/bin/env python
# coding: utf-8
# coding: utf-8
# In[
1
]:
# In[
]:
import
tkinter
as
tk
import
tkinter
as
tk
...
@@ -14,7 +14,7 @@ import requests
...
@@ -14,7 +14,7 @@ import requests
import
threading
import
threading
# In[
2
]:
# In[
]:
# 接收攝影機串流影像,採用多執行緒的方式,降低緩衝區堆疊圖幀的問題。
# 接收攝影機串流影像,採用多執行緒的方式,降低緩衝區堆疊圖幀的問題。
...
@@ -48,14 +48,21 @@ class ipcamCapture:
...
@@ -48,14 +48,21 @@ class ipcamCapture:
self
.
capture
.
release
()
self
.
capture
.
release
()
# In[
3
]:
# In[
]:
# api server environment
# api server environment
api_server
=
'http://192.168.5.205:8000'
api_server
=
'http://192.168.5.205:8000'
# In[4]:
# In[ ]:
# casecade 分類器載入
face_cascade
=
cv2
.
CascadeClassifier
(
"./model/cv2/haarcascade_frontalface_alt2.xml"
)
# In[ ]:
#Set up GUI
#Set up GUI
...
@@ -64,7 +71,7 @@ window.wm_title("人臉辨識打卡系統")
...
@@ -64,7 +71,7 @@ window.wm_title("人臉辨識打卡系統")
window
.
config
(
background
=
"#FFFFFF"
)
window
.
config
(
background
=
"#FFFFFF"
)
# In[
5
]:
# In[
]:
#Graphics window
#Graphics window
...
@@ -72,7 +79,7 @@ imageFrame = tk.Frame(window, width=600, height=500)
...
@@ -72,7 +79,7 @@ imageFrame = tk.Frame(window, width=600, height=500)
imageFrame
.
grid
(
row
=
1
,
column
=
0
,
rowspan
=
4
,
padx
=
10
,
pady
=
2
)
imageFrame
.
grid
(
row
=
1
,
column
=
0
,
rowspan
=
4
,
padx
=
10
,
pady
=
2
)
# In[
6
]:
# In[
]:
#Capture video frames
#Capture video frames
...
@@ -88,7 +95,7 @@ ipcam.start()
...
@@ -88,7 +95,7 @@ ipcam.start()
time
.
sleep
(
1
)
time
.
sleep
(
1
)
# In[
7
]:
# In[
]:
# result
# result
...
@@ -104,7 +111,7 @@ name=tk.Label(window,text='Allen',font=("Times New Roman", 20))
...
@@ -104,7 +111,7 @@ name=tk.Label(window,text='Allen',font=("Times New Roman", 20))
name
.
grid
(
row
=
4
,
column
=
1
)
name
.
grid
(
row
=
4
,
column
=
1
)
# In[
8
]:
# In[
]:
def
clock
(
measurments
):
def
clock
(
measurments
):
...
@@ -115,19 +122,22 @@ def clock(measurments):
...
@@ -115,19 +122,22 @@ def clock(measurments):
response_json
=
response
.
json
()
response_json
=
response
.
json
()
if
(
len
(
response_json
)
==
1
):
if
(
len
(
response_json
)
==
1
):
status_label
[
'text'
]
=
response_json
[
'error'
]
status_label
[
'text'
]
=
response_json
[
'error'
]
elif
(
len
(
response_json
)
==
4
):
elif
(
len
(
response_json
)
==
5
):
confidence
=
response_json
[
'confidence'
][
0
]
confidence
=
response_json
[
'confidence'
][
0
]
face_location
=
response_json
[
'face_location'
][
0
]
face_location
=
response_json
[
'face_location'
][
0
]
result_name
=
response_json
[
'name'
]
[
0
]
result_name
=
response_json
[
'name'
]
clock_time
=
response_json
[
'time'
]
clock_time
=
response_json
[
'time'
]
status_label
[
'text'
]
=
'辨識完成 請確認資料'
status_label
[
'text'
]
=
'辨識完成 請確認資料'
t
[
'text'
]
=
time
.
strftime
(
"
%
Y-
%
m-
%
d
%
H:
%
M:
%
S"
,
time
.
localtime
(
float
(
clock_time
)))
t
[
'text'
]
=
time
.
strftime
(
"
%
Y-
%
m-
%
d
%
H:
%
M:
%
S"
,
time
.
localtime
(
float
(
clock_time
)))
name
[
'text'
]
=
str
([
result_name
,
confidence
])
name
[
'text'
]
=
str
([
result_name
,
confidence
])
login_button
.
configure
(
text
=
"是"
,
command
=
lambda
:
submit
(
clock_time
,
result_name
,
measurments
))
login_button
.
configure
(
text
=
"是"
,
command
=
lambda
:
submit
(
clock_time
,
response_json
[
'uid'
][
0
],
measurments
))
logout_button
.
configure
(
text
=
"否"
,
command
=
lambda
:
retry
(
clock_time
,
result_name
,
measurments
))
logout_button
.
configure
(
text
=
"否"
,
command
=
lambda
:
retry
(
clock_time
,
response_json
[
'uid'
][
0
],
measurments
))
global
retry_button
retry_button
=
tk
.
Button
(
window
,
text
=
"重試"
,
command
=
empty_result
,
font
=
(
"標楷體"
,
20
))
retry_button
.
grid
(
row
=
5
,
column
=
3
)
# In[
9
]:
# In[
]:
def
empty_result
():
def
empty_result
():
...
@@ -136,50 +146,50 @@ def empty_result():
...
@@ -136,50 +146,50 @@ def empty_result():
name
[
'text'
]
=
''
name
[
'text'
]
=
''
login_button
.
configure
(
text
=
"上班打卡"
,
command
=
lambda
:
clock
(
'login_'
))
login_button
.
configure
(
text
=
"上班打卡"
,
command
=
lambda
:
clock
(
'login_'
))
logout_button
.
configure
(
text
=
"下班打卡"
,
command
=
lambda
:
clock
(
'logout_'
))
logout_button
.
configure
(
text
=
"下班打卡"
,
command
=
lambda
:
clock
(
'logout_'
))
global
retry_button
retry_button
.
destroy
()
# In[
10
]:
# In[
]:
def
submit
(
t
,
name
,
measurments
):
def
submit
(
t
,
uid
,
measurments
):
data
=
{
'time'
:
t
,
'
name'
:
name
,
'log'
:
measurments
,
'status'
:
'success'
}
data
=
{
'time'
:
t
,
'
uid'
:
uid
,
'log'
:
measurments
,
'status'
:
'success'
}
response
=
requests
.
post
(
os
.
path
.
join
(
api_server
,
'clock'
),
data
=
data
)
response
=
requests
.
post
(
os
.
path
.
join
(
api_server
,
'clock'
),
data
=
data
)
status_label
[
'text'
]
=
response
.
json
()[
'message'
]
if
(
measurments
==
'login_'
):
if
(
measurments
==
'login_'
):
msg
=
'上班加油!!'
msg
=
response
.
json
()[
'message'
]
+
'上班加油!!'
else
:
else
:
msg
=
'上班辛苦了 下班好好休息吧!!'
msg
=
response
.
json
()[
'message'
]
+
'上班辛苦了 下班好好休息吧!!'
status_label
[
'text'
]
=
msg
status_label
[
'text'
]
=
msg
status_label
.
after
(
3000
,
func
=
empty_result
)
status_label
.
after
(
3000
,
func
=
empty_result
)
# In[
11
]:
# In[
]:
def
retry
(
t
,
name
,
measurments
):
def
retry
(
t
,
name
,
measurments
):
error_window
=
tk
.
Toplevel
(
window
)
error_window
=
tk
.
Toplevel
(
window
)
error_window
.
geometry
(
'300x200'
)
error_window
.
geometry
(
'300x200'
)
error_window
.
title
(
'請輸入您的
姓名
以利後續訓練'
)
error_window
.
title
(
'請輸入您的
ID
以利後續訓練'
)
tk
.
Label
(
error_window
,
text
=
'
姓名: '
,
font
=
(
"標楷體
"
,
20
))
.
grid
(
row
=
0
,
column
=
0
)
tk
.
Label
(
error_window
,
text
=
'
ID: '
,
font
=
(
"Times New Roman
"
,
20
))
.
grid
(
row
=
0
,
column
=
0
)
currect_
name
=
tk
.
StringVar
()
currect_
uid
=
tk
.
StringVar
()
entry_currect_
name
=
tk
.
Entry
(
error_window
,
textvariable
=
currect_name
)
entry_currect_
uid
=
tk
.
Entry
(
error_window
,
textvariable
=
currect_uid
)
entry_currect_
name
.
grid
(
row
=
0
,
column
=
1
)
entry_currect_
uid
.
grid
(
row
=
0
,
column
=
1
)
button_submit
=
tk
.
Button
(
error_window
,
text
=
'提交'
,
font
=
(
"標楷體"
,
20
),
command
=
lambda
:
retry_ok
(
error_window
,
t
,
entry_currect_
name
.
get
(),
measurments
))
button_submit
=
tk
.
Button
(
error_window
,
text
=
'提交'
,
font
=
(
"標楷體"
,
20
),
command
=
lambda
:
retry_ok
(
error_window
,
t
,
entry_currect_
uid
.
get
(),
measurments
))
button_submit
.
grid
(
row
=
1
,
column
=
0
,
columnspan
=
2
)
button_submit
.
grid
(
row
=
1
,
column
=
0
,
columnspan
=
2
)
def
retry_ok
(
error_window
,
t
,
name
,
measurments
):
def
retry_ok
(
error_window
,
t
,
uid
,
measurments
):
error_window
.
destroy
()
error_window
.
destroy
()
data
=
{
'time'
:
t
,
'
name'
:
name
,
'log'
:
measurments
,
'status'
:
'error_'
}
data
=
{
'time'
:
t
,
'
uid'
:
uid
,
'log'
:
measurments
,
'status'
:
'error_'
}
response
=
requests
.
post
(
os
.
path
.
join
(
api_server
,
'clock'
),
data
=
data
)
response
=
requests
.
post
(
os
.
path
.
join
(
api_server
,
'clock'
),
data
=
data
)
status_label
[
'text'
]
=
response
.
json
()[
'message'
]
if
(
measurments
==
'login_'
):
if
(
measurments
==
'login_'
):
msg
=
'上班加油!!'
msg
=
response
.
json
()[
'message'
]
+
'上班加油!!'
else
:
else
:
msg
=
'上班辛苦了 下班好好休息吧!!'
msg
=
response
.
json
()[
'message'
]
+
'上班辛苦了 下班好好休息吧!!'
status_label
[
'text'
]
=
msg
status_label
[
'text'
]
=
msg
status_label
.
after
(
3000
,
func
=
empty_result
)
status_label
.
after
(
3000
,
func
=
empty_result
)
# In[
12
]:
# In[
]:
# button
# button
...
@@ -187,9 +197,10 @@ login_button= tk.Button(window,text="上班打卡",command=lambda:clock('login_'
...
@@ -187,9 +197,10 @@ login_button= tk.Button(window,text="上班打卡",command=lambda:clock('login_'
login_button
.
grid
(
row
=
5
,
column
=
0
)
login_button
.
grid
(
row
=
5
,
column
=
0
)
logout_button
=
tk
.
Button
(
window
,
text
=
"下班打卡"
,
command
=
lambda
:
clock
(
'logout_'
),
font
=
(
"標楷體"
,
20
))
logout_button
=
tk
.
Button
(
window
,
text
=
"下班打卡"
,
command
=
lambda
:
clock
(
'logout_'
),
font
=
(
"標楷體"
,
20
))
logout_button
.
grid
(
row
=
5
,
column
=
1
)
logout_button
.
grid
(
row
=
5
,
column
=
1
)
retry_button
=
None
# In[
13
]:
# In[
]:
def
show_frame
():
def
show_frame
():
...
@@ -198,12 +209,12 @@ def show_frame():
...
@@ -198,12 +209,12 @@ def show_frame():
# h,w=frame.shape[:2]
# h,w=frame.shape[:2]
# frame=cv2.resize(frame,(int(w/2),int(h/2)))
# frame=cv2.resize(frame,(int(w/2),int(h/2)))
#
faces = face_cascade.detectMultiScale(frame,scaleFactor=1.1,minNeighbors=3)
faces
=
face_cascade
.
detectMultiScale
(
frame
,
scaleFactor
=
1.1
,
minNeighbors
=
3
)
#
if(len(faces)>0):
if
(
len
(
faces
)
>
0
):
#
for f in faces:
for
f
in
faces
:
#
x,y,w,h=f
x
,
y
,
w
,
h
=
f
#
margin=10
margin
=
10
#
cv2.rectangle(frame,(x-margin//2,y-margin//2),(x+w+margin//2,y+h+margin//2),(0,0,255))
cv2
.
rectangle
(
frame
,(
x
-
margin
//
2
,
y
-
margin
//
2
),(
x
+
w
+
margin
//
2
,
y
+
h
+
margin
//
2
),(
0
,
0
,
255
))
# cv2.putText(frame,time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()),(0,30)
# cv2.putText(frame,time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()),(0,30)
# ,cv2.FONT_HERSHEY_TRIPLEX,1, (0, 255, 255), 1, cv2.LINE_AA)
# ,cv2.FONT_HERSHEY_TRIPLEX,1, (0, 255, 255), 1, cv2.LINE_AA)
cv2image
=
cv2
.
cvtColor
(
frame
,
cv2
.
COLOR_BGR2RGBA
)
cv2image
=
cv2
.
cvtColor
(
frame
,
cv2
.
COLOR_BGR2RGBA
)
...
@@ -214,7 +225,7 @@ def show_frame():
...
@@ -214,7 +225,7 @@ def show_frame():
lmain
.
after
(
10
,
show_frame
)
lmain
.
after
(
10
,
show_frame
)
# In[
14
]:
# In[
]:
show_frame
()
#Display 2
show_frame
()
#Display 2
...
...
Face-Clock-Insert-API.py
View file @
93f486df
...
@@ -58,7 +58,7 @@ api_server='http://192.168.5.205:8000'
...
@@ -58,7 +58,7 @@ api_server='http://192.168.5.205:8000'
# casecade 分類器載入
# casecade 分類器載入
face_cascade
=
cv2
.
CascadeClassifier
(
".
.
/model/cv2/haarcascade_frontalface_alt2.xml"
)
face_cascade
=
cv2
.
CascadeClassifier
(
"./model/cv2/haarcascade_frontalface_alt2.xml"
)
# In[5]:
# In[5]:
...
@@ -81,7 +81,7 @@ time.sleep(1)
...
@@ -81,7 +81,7 @@ time.sleep(1)
imageFrame
=
tk
.
Frame
(
window
,
width
=
1024
,
height
=
980
)
imageFrame
=
tk
.
Frame
(
window
,
width
=
1024
,
height
=
980
)
imageFrame
.
grid
(
row
=
1
,
column
=
0
,
rowspan
=
4
,
padx
=
10
,
pady
=
2
)
imageFrame
.
grid
(
row
=
1
,
column
=
0
,
rowspan
=
5
,
padx
=
10
,
pady
=
2
)
#root.protocol('WM_DELETE_WINDOW', detector)
#root.protocol('WM_DELETE_WINDOW', detector)
lmain
=
tk
.
Label
(
imageFrame
)
lmain
=
tk
.
Label
(
imageFrame
)
lmain
.
grid
(
row
=
0
,
column
=
0
)
lmain
.
grid
(
row
=
0
,
column
=
0
)
...
@@ -93,31 +93,31 @@ window.config(cursor="arrow")
...
@@ -93,31 +93,31 @@ window.config(cursor="arrow")
status_label
=
tk
.
Label
(
window
,
text
=
'歡迎使用本系統'
,
font
=
(
"標楷體"
,
20
))
status_label
=
tk
.
Label
(
window
,
text
=
'歡迎使用本系統'
,
font
=
(
"標楷體"
,
20
))
status_label
.
grid
(
row
=
0
,
column
=
0
,
columnspan
=
3
)
status_label
.
grid
(
row
=
0
,
column
=
0
,
columnspan
=
3
)
time_label
=
tk
.
Label
(
window
,
text
=
'時間:'
,
font
=
(
"標楷體"
,
20
))
uid_label
=
tk
.
Label
(
window
,
text
=
'ID:'
,
font
=
(
"標楷體"
,
20
))
time_label
.
grid
(
row
=
0
,
column
=
1
)
uid_label
.
grid
(
row
=
1
,
column
=
1
)
t
=
tk
.
Label
(
window
,
text
=
time
.
strftime
(
"
%
Y-
%
m-
%
d
%
H:
%
M:
%
S"
,
time
.
localtime
()),
font
=
(
"Times New Roman"
,
20
))
t
.
grid
(
row
=
0
,
column
=
2
)
name_label
=
tk
.
Label
(
window
,
text
=
'姓名: '
,
font
=
(
"標楷體"
,
20
))
name_label
=
tk
.
Label
(
window
,
text
=
'姓名: '
,
font
=
(
"標楷體"
,
20
))
name_label
.
grid
(
row
=
1
,
column
=
1
)
name_label
.
grid
(
row
=
2
,
column
=
1
)
english_name
=
tk
.
Label
(
window
,
text
=
'英文名: '
,
font
=
(
"標楷體"
,
20
))
english_name
=
tk
.
Label
(
window
,
text
=
'英文名: '
,
font
=
(
"標楷體"
,
20
))
english_name
.
grid
(
row
=
2
,
column
=
1
,
pady
=
10
)
english_name
.
grid
(
row
=
3
,
column
=
1
,
pady
=
10
)
tel
=
tk
.
Label
(
window
,
text
=
'電話: '
,
font
=
(
"標楷體"
,
20
))
tel
=
tk
.
Label
(
window
,
text
=
'電話: '
,
font
=
(
"標楷體"
,
20
))
tel
.
grid
(
row
=
3
,
column
=
1
,
pady
=
10
)
tel
.
grid
(
row
=
4
,
column
=
1
,
pady
=
10
)
since_year
=
tk
.
Label
(
window
,
text
=
'入學年: '
,
font
=
(
"標楷體"
,
20
))
since_year
=
tk
.
Label
(
window
,
text
=
'入學年: '
,
font
=
(
"標楷體"
,
20
))
since_year
.
grid
(
row
=
4
,
column
=
1
,
pady
=
10
)
since_year
.
grid
(
row
=
5
,
column
=
1
,
pady
=
10
)
# In[8]:
# In[8]:
name_text
=
tk
.
Text
(
window
,
height
=
1
,
width
=
10
,
font
=
(
"標楷體"
,
20
))
uid_text
=
tk
.
Entry
(
window
,
font
=
(
"Times New Roman"
,
20
))
name_text
.
grid
(
row
=
1
,
column
=
2
)
uid_text
.
grid
(
row
=
1
,
column
=
2
)
english_name_text
=
tk
.
Text
(
window
,
height
=
1
,
width
=
10
,
font
=
(
"標楷體"
,
20
))
name_text
=
tk
.
Entry
(
window
,
font
=
(
"標楷體"
,
20
))
english_name_text
.
grid
(
row
=
2
,
column
=
2
,
pady
=
10
)
name_text
.
grid
(
row
=
2
,
column
=
2
)
phone_text
=
tk
.
Text
(
window
,
height
=
1
,
width
=
10
,
font
=
(
"標楷體"
,
20
))
english_name_text
=
tk
.
Entry
(
window
,
font
=
(
"標楷體"
,
20
))
phone_text
.
grid
(
row
=
3
,
column
=
2
,
pady
=
10
)
english_name_text
.
grid
(
row
=
3
,
column
=
2
,
pady
=
10
)
since_year_text
=
tk
.
Text
(
window
,
height
=
1
,
width
=
10
,
font
=
(
"標楷體"
,
20
))
phone_text
=
tk
.
Entry
(
window
,
font
=
(
"標楷體"
,
20
))
since_year_text
.
grid
(
row
=
4
,
column
=
2
,
pady
=
10
)
phone_text
.
grid
(
row
=
4
,
column
=
2
,
pady
=
10
)
since_year_text
=
tk
.
Entry
(
window
,
font
=
(
"標楷體"
,
20
))
since_year_text
.
grid
(
row
=
5
,
column
=
2
,
pady
=
10
)
# In[9]:
# In[9]:
...
@@ -147,26 +147,27 @@ def upload():
...
@@ -147,26 +147,27 @@ def upload():
frame
=
ipcam
.
getframe
()
frame
=
ipcam
.
getframe
()
imencoded
=
cv2
.
imencode
(
".jpg"
,
frame
)[
1
]
imencoded
=
cv2
.
imencode
(
".jpg"
,
frame
)[
1
]
file
=
{
'file'
:
(
'image.jpg'
,
imencoded
.
tostring
(),
'image/jpeg'
,
{
'Expires'
:
'0'
})}
file
=
{
'file'
:
(
'image.jpg'
,
imencoded
.
tostring
(),
'image/jpeg'
,
{
'Expires'
:
'0'
})}
engname
=
english_name_text
.
get
(
1.0
,
tk
.
END
)
.
split
(
'
\n
'
)[
0
]
uid
=
uid_text
.
get
()
if
(
len
(
engname
)
==
0
):
if
(
len
(
uid
)
==
0
):
status_label
[
'text'
]
=
'請先
輸入英文名稱在上傳影像
'
status_label
[
'text'
]
=
'請先
提交或輸入id後在嘗試
'
else
:
else
:
data
=
{
'
name'
:
engname
}
data
=
{
'
uid'
:
uid
}
response
=
requests
.
post
(
os
.
path
.
join
(
api_server
,
'upload'
,
'image'
),
files
=
file
,
data
=
data
)
response
=
requests
.
post
(
os
.
path
.
join
(
api_server
,
'upload'
,
'image'
),
files
=
file
,
data
=
data
)
status_label
[
'text'
]
=
engname
+
'照片上傳成功'
status_label
[
'text'
]
=
response
.
json
()
def
submit
():
def
submit
():
name
=
name_text
.
get
(
1.0
,
tk
.
END
)
.
split
(
'
\n
'
)[
0
]
name
=
name_text
.
get
(
)
engname
=
english_name_text
.
get
(
1.0
,
tk
.
END
)
.
split
(
'
\n
'
)[
0
]
engname
=
english_name_text
.
get
(
)
phone
=
phone_text
.
get
(
1.0
,
tk
.
END
)
.
split
(
'
\n
'
)[
0
]
phone
=
phone_text
.
get
(
)
years
=
since_year_text
.
get
(
1.0
,
tk
.
END
)
.
split
(
'
\n
'
)[
0
]
years
=
since_year_text
.
get
(
)
if
(
is_number
(
phone
)
and
is_number
(
years
)):
if
(
is_number
(
phone
)
and
is_number
(
years
)):
data
=
{
'name'
:
name
,
'engname'
:
engname
,
'phone'
:
phone
,
'years'
:
years
}
data
=
{
'name'
:
name
,
'engname'
:
engname
,
'phone'
:
phone
,
'years'
:
years
}
response
=
requests
.
post
(
os
.
path
.
join
(
api_server
,
'insert'
),
data
=
data
)
response
=
requests
.
post
(
os
.
path
.
join
(
api_server
,
'insert'
),
data
=
data
)
uid_text
.
select_clear
()
uid_text
.
insert
(
0
,
response
.
json
()[
'message'
])
else
:
else
:
status_label
[
'text'
]
=
'輸入格式錯誤請重新輸入'
status_label
[
'text'
]
=
'輸入格式錯誤請重新輸入'
def
video_loop
():
def
video_loop
():
t
[
'text'
]
=
time
.
strftime
(
"
%
Y-
%
m-
%
d
%
H:
%
M:
%
S"
,
time
.
localtime
())
frame
=
ipcam
.
getframe
()
frame
=
ipcam
.
getframe
()
h
,
w
=
frame
.
shape
[:
2
]
h
,
w
=
frame
.
shape
[:
2
]
img
=
cv2
.
resize
(
frame
,(
int
(
w
/
2
),
int
(
h
/
2
)))
img
=
cv2
.
resize
(
frame
,(
int
(
w
/
2
),
int
(
h
/
2
)))
...
@@ -188,10 +189,21 @@ def video_loop():
...
@@ -188,10 +189,21 @@ def video_loop():
loginbtn
=
tk
.
Button
(
window
,
text
=
"上傳照片"
,
command
=
upload
,
height
=
1
,
font
=
(
"標楷體"
,
20
))
loginbtn
=
tk
.
Button
(
window
,
text
=
"上傳照片"
,
command
=
upload
,
height
=
1
,
font
=
(
"標楷體"
,
20
))
loginbtn
.
grid
(
row
=
5
,
column
=
0
,
padx
=
10
,
pady
=
2
)
loginbtn
.
grid
(
row
=
6
,
column
=
0
,
padx
=
10
,
pady
=
2
)
logoutbtn
=
tk
.
Button
(
window
,
text
=
"提交"
,
command
=
submit
,
height
=
1
,
font
=
(
"標楷體"
,
20
))
logoutbtn
=
tk
.
Button
(
window
,
text
=
"提交"
,
command
=
submit
,
height
=
1
,
font
=
(
"標楷體"
,
20
))
logoutbtn
.
grid
(
row
=
5
,
column
=
1
,
padx
=
10
,
pady
=
2
)
logoutbtn
.
grid
(
row
=
6
,
column
=
1
,
padx
=
10
,
pady
=
2
)
video_loop
()
video_loop
()
window
.
mainloop
()
window
.
mainloop
()
# In[ ]:
# In[ ]:
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment