-
Notifications
You must be signed in to change notification settings - Fork 7
/
demo-04.html
83 lines (72 loc) · 2.11 KB
/
demo-04.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Hyponic Reader</title>
<style>
.video {
position:relative;
}
.video .camera,
.video .overlay {
position:absolute;
top:0;
}
</style>
</head>
<body>
<p>See console log for pulse info</p>
<div style="display:block">
<audio id="audio-countdown" controls loop>
<source src="assets/audio/hyponic/countdown.mp3" type="audio/mpeg">
<source src="assets/audio/hyponic/countdown.ogg" type="audio/ogg">
</audio>
<audio controls loop>
<source src="assets/audio/hyponic/music.mp3" type="audio/mpeg">
<source src="assets/audio/hyponic/music.ogg" type="audio/ogg">
</audio>
</div>
<div id="heart"></div>
<div id="camera" class="video"></div>
<script type="text/javascript" src="assets/js/lib/underscore-min.js"></script>
<script type="text/javascript" src="assets/js/lib/headtrackr.min.js"></script>
<script type="text/javascript" src="assets/js/core/pm.js"></script>
<script type="text/javascript" src="assets/js/detectors/face.js"></script>
<script type="text/javascript" src="assets/js/detectors/pulse.js"></script>
<script type="text/javascript" src="assets/js/outputs/heart.js"></script>
<script type="text/javascript">
var myFace = PM.Face({
target: '#camera',
overlay: false
});
var myPulse = PM.Pulse({
target: '#camera',
face: myFace
});
var myHeart = PM.Heart({
target: '#heart',
width: 100,
height: 100,
size: 25
});
var myCountdown = document.querySelector('#audio-countdown');
PM.listen('pulseupdate', function(data) {
console.log('pulseupdate | bpm: ' + data.target.bpm + ' | heartrate: ' + data.target.heartrate);
myCountdown.playbackRate = data.target.bpm / 60;
myHeart.pulse(data.target.bpm);
});
// Added some console logs
PM.listen('facestatus', function(data) {
console.log('facestatus | status: ' + data.event.status);
});
/*
PM.listen('faceupdate', function(data) {
console.log('faceupdate | confidence: ' + data.event.confidence);
});
PM.listen('headupdate', function(data) {
console.log('headupdate | x: ' + data.event.x + ' | y: ' + data.event.y + ' | z: ' + data.event.z);
});
*/
</script>
</body>
</html>