Toggle navigation
Toggle navigation
This project
Loading...
Sign in
2020-2-capstone-design2
/
2014104149
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
Graduate
2020-11-26 03:52:51 +0000
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
bf0df067e5d6082602214255f87cb061673dae41
bf0df067
1 parent
5da7139b
Resize stream input
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
16 deletions
flask/templates/index.html
flask/templates/register.html
flask/templates/index.html
View file @
bf0df06
...
...
@@ -21,6 +21,26 @@
<script
type=
'text/javascript'
src=
"{{url_for('static', filename='js/utils.js')}}"
></script>
<script
type=
'text/javascript'
src=
"https://code.jquery.com/jquery-1.12.4.min.js"
></script>
<script
type=
'text/javascript'
>
function
init
()
{
let
video
=
document
.
getElementById
(
"videoInput"
);
if
(
navigator
.
mediaDevices
.
getUserMedia
){
navigator
.
mediaDevices
.
getUserMedia
({
video
:
true
})
.
then
(
function
(
stream
)
{
video
.
srcObject
=
stream
;
video
.
addEventListener
(
'canplay'
,
()
=>
{
video
.
width
=
video
.
videoWidth
;
video
.
height
=
video
.
videoHeight
;
load_cascade
();
});
}).
catch
(
function
(
err0r
)
{
console
.
log
(
"Something went wrong!"
);
streaming
=
false
;
});
}
}
function
load_cascade
()
{
let
faceCascadeFile
=
'haarcascade_frontalface_default.xml'
...
...
@@ -31,22 +51,12 @@ function load_cascade()
});
}
function
main
()
{
let
video
=
document
.
getElementById
(
"videoInput"
);
let
canvasOutput
=
document
.
getElementById
(
"canvasOutput"
);
let
canvasContext
=
canvasOutput
.
getContext
(
'2d'
);
if
(
navigator
.
mediaDevices
.
getUserMedia
){
navigator
.
mediaDevices
.
getUserMedia
({
video
:
true
})
.
then
(
function
(
stream
)
{
video
.
srcObject
=
stream
;
}).
catch
(
function
(
err0r
)
{
console
.
log
(
"Something went wrong!"
);
streaming
=
false
;
});
}
let
src
=
new
cv
.
Mat
(
video
.
height
,
video
.
width
,
cv
.
CV_8UC4
);
let
dst
=
new
cv
.
Mat
(
video
.
height
,
video
.
width
,
cv
.
CV_8UC4
);
let
gray
=
new
cv
.
Mat
();
...
...
@@ -151,6 +161,7 @@ function processVideo() {
});
}
}
// to do resize preview
cv
.
imshow
(
'canvasOutput'
,
dst
);
// schedule the next one.
let
delay
=
1000
/
FPS
-
(
Date
.
now
()
-
begin
);
...
...
@@ -163,10 +174,10 @@ setTimeout(processVideo, 0);
}
</script>
</head>
<body
onload=
"cv['onRuntimeInitialized']=()=>{
load_cascade
(); };"
>
<body
onload=
"cv['onRuntimeInitialized']=()=>{
init
(); };"
>
<div
id=
"container"
>
<video
autoplay=
"true"
id=
"videoInput"
width=
640
height=
480
style=
"display: none
;"
></video>
<canvas
id=
"canvasOutput"
width=
640
height=
480
></canvas>
<video
autoplay=
"true"
id=
"videoInput"
style=
"display: none; object-fit: cover
;"
></video>
<canvas
id=
"canvasOutput"
></canvas>
</div>
</body>
</html>
...
...
flask/templates/register.html
View file @
bf0df06
...
...
@@ -72,9 +72,9 @@ function detect_face()
let
sender
=
document
.
getElementById
(
"sender"
);
sender
.
disabled
=
false
;
}
if
(
dst
.
cols
>
$
(
window
).
width
())
if
(
dst
.
cols
>
$
(
window
).
width
()
||
dst
.
rows
>
$
(
window
).
height
()
)
{
let
ratio
=
$
(
window
).
width
()
/
parseFloat
(
dst
.
cols
);
let
ratio
=
Math
.
min
(
$
(
window
).
width
()
/
parseFloat
(
dst
.
cols
),
$
(
window
).
height
()
/
parseFloat
(
dst
.
rows
)
);
let
dsize
=
new
cv
.
Size
(
dst
.
cols
*
ratio
,
dst
.
rows
*
ratio
);
cv
.
resize
(
dst
,
dst
,
dsize
,
0
,
0
,
cv
.
INTER_AREA
);
}
...
...
Please
register
or
login
to post a comment