forked from liuliu/ccv
-
Notifications
You must be signed in to change notification settings - Fork 485
/
Copy pathvideo.html
executable file
·92 lines (83 loc) · 2.86 KB
/
video.html
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<title>jQuery FaceDetection Examples</title>
<link rel="stylesheet" href="css/styles.css">
<style>
.video-container {
position: relative;
width: 260px;
height: auto;
margin: 20px auto;
border: 10px solid #fff;
box-shadow: 0 5px 5px #000;
}
.video {
display: block;
width: 100%;
height: auto;
}
.face {
position: absolute;
border: 2px solid #FFF;
}
</style>
</head>
<body>
<a href="http://facedetection.jaysalvat.com">
<img class="logo" src="img/logo.svg">
</a>
<div class="video-container">
<video id="video" class="video" loop autoplay>
<source src="assets/video.mp4" type="video/mp4">
<source src="assets/video.ogv" type="video/ogg">
<source src="assets/video.webm" type="video/webm">
</video>
</div>
<a id="try-it" href="#">
<img class="button-try" src="img/tryit.svg">
</a>
<a class="button-visit" href="http://facedetection.jaysalvat.com">Visit the website</a>
<script src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
<script src="../dist/jquery.facedetection.js"></script>
<script>
/* global $ */
$(function () {
"use strict";
$('#try-it').click(function (e) {
e.preventDefault();
$('.face').remove();
if ($('#video')[0].paused) {
$('#video')[0].play();
return;
} else {
$('#video')[0].pause();
}
$('#video').faceDetection({
interval: 1,
complete: function (faces) {
for (var i = 0; i < faces.length; i++) {
$('<div>', {
'class':'face',
'css': {
'position': 'absolute',
'left': faces[i].x + 'px',
'top': faces[i].y + 'px',
'width': faces[i].width + 'px',
'height': faces[i].height + 'px'
}
})
.insertAfter(this);
}
},
error:function (code, message) {
alert('Error: ' + message);
}
});
});
});
</script>
</body>
</html>