forked from liuliu/ccv
-
Notifications
You must be signed in to change notification settings - Fork 485
/
Copy pathpicture.html
executable file
·80 lines (72 loc) · 2.56 KB
/
picture.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
<!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>
.picture-container {
position: relative;
width: 600px;
height: auto;
margin: 20px auto;
border: 10px solid #fff;
box-shadow: 0 5px 5px #000;
}
.picture {
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="picture-container">
<img id="picture" class="picture" src="assets/picture.jpg">
</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();
$('#picture').faceDetection({
complete: function (faces) {
for (var i = 0; i < faces.length; i++) {
$('<div>', {
'class':'face',
'css': {
'position': 'absolute',
'left': faces[i].x * faces[i].scaleX + 'px',
'top': faces[i].y * faces[i].scaleY + 'px',
'width': faces[i].width * faces[i].scaleX + 'px',
'height': faces[i].height * faces[i].scaleY + 'px'
}
})
.insertAfter(this);
}
},
error:function (code, message) {
alert('Error: ' + message);
}
});
});
});
</script>
</body>
</html>