Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
2
2020-101
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Sachith Fernando
2020-101
Commits
aab59071
Commit
aab59071
authored
Oct 18, 2020
by
LiniEisha
Committed by
I.K Seneviratne
Oct 19, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Commiting IT17098960's changes
parent
db24e45e
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
135 additions
and
0 deletions
+135
-0
AttendanceApp/record.py
AttendanceApp/record.py
+63
-0
AttendanceApp/templates/AttendanceApp/Initiate_Lecture.html
AttendanceApp/templates/AttendanceApp/Initiate_Lecture.html
+72
-0
No files found.
AttendanceApp/record.py
0 → 100644
View file @
aab59071
import
numpy
as
np
import
os
import
cv2
import
getpass
import
time
from
datetime
import
datetime
filename
=
'video.avi'
frames_per_second
=
24.0
res
=
'720p'
# Set resolution for the video capture
# Function adapted from https://kirr.co/0l6qmh
def
change_res
(
cap
,
width
,
height
):
cap
.
set
(
3
,
width
)
cap
.
set
(
4
,
height
)
# Standard Video Dimensions Sizes
STD_DIMENSIONS
=
{
"480p"
:
(
640
,
480
),
"720p"
:
(
1280
,
720
),
"1080p"
:
(
1920
,
1080
),
"4k"
:
(
3840
,
2160
),
}
# grab resolution dimensions and set video capture to it.
def
get_dims
(
cap
,
res
=
'1080p'
):
width
,
height
=
STD_DIMENSIONS
[
"480p"
]
if
res
in
STD_DIMENSIONS
:
width
,
height
=
STD_DIMENSIONS
[
res
]
## change the current caputre device
## to the resulting resolution
change_res
(
cap
,
width
,
height
)
return
width
,
height
# Video Encoding, might require additional installs
# Types of Codes: http://www.fourcc.org/codecs.php
VIDEO_TYPE
=
{
'avi'
:
cv2
.
VideoWriter_fourcc
(
*
'XVID'
),
#'mp4': cv2.VideoWriter_fourcc(*'H264'),
'mp4'
:
cv2
.
VideoWriter_fourcc
(
*
'XVID'
),
}
def
get_video_type
(
filename
):
filename
,
ext
=
os
.
path
.
splitext
(
filename
)
if
ext
in
VIDEO_TYPE
:
return
VIDEO_TYPE
[
ext
]
return
VIDEO_TYPE
[
'avi'
]
def
initiate
():
cap
=
cv2
.
VideoCapture
(
0
)
out
=
cv2
.
VideoWriter
(
filename
,
get_video_type
(
filename
),
25
,
get_dims
(
cap
,
res
))
while
True
:
ret
,
frame
=
cap
.
read
()
out
.
write
(
frame
)
cv2
.
imshow
(
'frame'
,
frame
)
if
cv2
.
waitKey
(
1
)
&
0xFF
==
ord
(
'q'
):
break
cap
.
release
()
out
.
release
()
cv2
.
destroyAllWindows
()
\ No newline at end of file
AttendanceApp/templates/AttendanceApp/Initiate_Lecture.html
0 → 100644
View file @
aab59071
{% extends 'FirstApp/template.html' %}
<!DOCTYPE html>
<html
lang=
"en"
>
<head>
<meta
charset=
"UTF-8"
>
<title>
Title
</title>
</head>
<body>
{% block javascript %}
{% load static %}
<!-- Bootstrap core JavaScript-->
<script
src=
"{% static 'FirstApp/vendor/jquery/jquery.min.js' %}"
></script>
<script
src=
"{% static 'FirstApp/vendor/bootstrap/js/bootstrap.bundle.min.js' %}"
></script>
<!-- Page level plugins -->
<script
src=
"{% static 'FirstApp/vendor/datatables/jquery.dataTables.min.js' %}"
></script>
<script
src=
"{% static 'FirstApp/vendor/datatables/dataTables.bootstrap4.min.js' %}"
></script>
<!-- Page level custom scripts -->
<script
src=
"{% static 'FirstApp/js/demo/datatables-demo.js' %}"
></script>
<!-- Core plugin JavaScript-->
<script
src=
"{% static 'FirstApp/vendor/jquery-easing/jquery.easing.min.js' %}"
></script>
<!-- Load TensorFlow.js -->
<script
src=
"https://unpkg.com/@tensorflow/tfjs"
></script>
<!-- Load Posenet -->
<script
src=
"https://unpkg.com/@tensorflow-models/posenet"
>
</script>
<script
type=
"text/javascript"
>
$
(
document
).
ready
(
function
()
{
$
(
'
#initiate_btn
'
).
click
(
function
()
{
fetch
(
'
http://127.0.0.1:8000/attendance/process-initiate-lecture
'
)
.
then
((
res
)
=>
res
.
json
())
.
then
((
out
)
=>
alert
(
out
.
response
))
.
catch
((
err
)
=>
alert
(
'
error:
'
+
err
))
});
})
</script>
{% endblock %}
{% block 'container-fluid' %}
<div
class=
"container"
>
<div
class=
"row p-4"
>
<div
class=
"col-lg-12"
>
<div
class=
"text-center"
>
<div
class=
"card"
>
<div
class=
"card-header"
>
<h4
class=
"card-title"
>
Starting the lecture....
</h4>
</div>
<div
class=
"card-body"
>
<button
type=
"button"
class=
"btn btn-success"
id=
"initiate_btn"
>
Initiate Lecture
</button>
</div>
</div>
</div>
</div>
</div>
</div>
{% endblock %}
</body>
</html>
\ No newline at end of file
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