-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
55 lines (50 loc) · 1.57 KB
/
index.html
File metadata and controls
55 lines (50 loc) · 1.57 KB
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
<html>
<head>
<title>AdHell</title>
</head>
<body>
<div align="center"><video id="video" width="500" src="bb.mkv" controls autoplay></video></div>
<div align="center"><video id="you" autoplay></video></div>
<script src="jquery-3.5.1.min.js"></script>
<script src="face-api.min.js"></script>
<script>
var video = document.getElementById('you');
var advideo = document.getElementById("video");
$( document ).ready(function() {
run();
});
async function run() {
setInterval(function(){ checkFaces(); }, 1000);
// load the models
await faceapi.loadMtcnnModel('/')
await faceapi.loadFaceRecognitionModel('/')
// try to access users webcam and stream the images
// to the video element
const videoEl = document.getElementById('you')
navigator.getUserMedia(
{ video: {} },
stream => videoEl.srcObject = stream,
err => console.error(err)
)
}
async function checkFaces() {
const mtcnnForwardParams = {
// limiting the search space to larger faces for webcam detection
minFaceSize: 200
}
const mtcnnResults = await faceapi.mtcnn(document.getElementById('you'), mtcnnForwardParams);
//faceapi.drawDetection('overlay', mtcnnResults.map(res => res.faceDetection), { withScore: false })
if (mtcnnResults.length == 0) {
if (!advideo.paused) {
advideo.pause();
}
} else {
if (advideo.paused) {
advideo.play();
}
}
console.log(mtcnnResults.length);
}
</script>
</body>
</html>