FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
Face-Detection-JavaScript/script.js at master · ericbashir/Face-Detection-JavaScript · GitHub
ericbashir
/
Face-Detection-JavaScript
Public
forked from
WebDevSimplified/Face-Detection-JavaScript
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
Face-Detection-JavaScript
/
script.js
Copy path
More file actions
More file actions
Latest commit
History
History
History
31 lines (28 loc) · 1.18 KB
Breadcrumbs
Face-Detection-JavaScript
/
script.js
Copy path
File metadata and controls
31 lines (28 loc) · 1.18 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
const
video
=
document
.
getElementById
(
'video'
)
Promise
.
all
(
[
faceapi
.
nets
.
tinyFaceDetector
.
loadFromUri
(
'/models'
)
,
faceapi
.
nets
.
faceLandmark68Net
.
loadFromUri
(
'/models'
)
,
faceapi
.
nets
.
faceRecognitionNet
.
loadFromUri
(
'/models'
)
,
faceapi
.
nets
.
faceExpressionNet
.
loadFromUri
(
'/models'
)
]
)
.
then
(
startVideo
)
function
startVideo
(
)
{
navigator
.
getUserMedia
(
{
video
:
{
}
}
,
stream
=>
video
.
srcObject
=
stream
,
err
=>
console
.
error
(
err
)
)
}
video
.
addEventListener
(
'play'
,
(
)
=>
{
const
canvas
=
faceapi
.
createCanvasFromMedia
(
video
)
document
.
body
.
append
(
canvas
)
const
displaySize
=
{
width
:
video
.
width
,
height
:
video
.
height
}
faceapi
.
matchDimensions
(
canvas
,
displaySize
)
setInterval
(
async
(
)
=>
{
const
detections
=
await
faceapi
.
detectAllFaces
(
video
,
new
faceapi
.
TinyFaceDetectorOptions
(
)
)
.
withFaceLandmarks
(
)
.
withFaceExpressions
(
)
const
resizedDetections
=
faceapi
.
resizeResults
(
detections
,
displaySize
)
canvas
.
getContext
(
'2d'
)
.
clearRect
(
0
,
0
,
canvas
.
width
,
canvas
.
height
)
faceapi
.
draw
.
drawDetections
(
canvas
,
resizedDetections
)
faceapi
.
draw
.
drawFaceLandmarks
(
canvas
,
resizedDetections
)
faceapi
.
draw
.
drawFaceExpressions
(
canvas
,
resizedDetections
)
}
,
100
)
}
)
Back
|
FazBrowse Home
|
New Git URL