1
- const video = document . querySelector ( '.webcam' ) ;
2
- const canvas = document . querySelector ( '.video' ) ;
3
- const ctx = canvas . getContext ( '2d' ) ;
4
- const faceCanvas = document . querySelector ( '.face' ) ;
5
- const faceCtx = faceCanvas . getContext ( '2d' ) ;
1
+ // The face detection does not work on all browsers and operating systems.
2
+ // If you are getting a `Face detection service unavailable` error or similar,
3
+ // it's possible that it won't work for you at the moment.
4
+
5
+ const video = document . querySelector ( ".webcam" ) ;
6
+ const canvas = document . querySelector ( ".video" ) ;
7
+ const ctx = canvas . getContext ( "2d" ) ;
8
+ const faceCanvas = document . querySelector ( ".face" ) ;
9
+ const faceCtx = faceCanvas . getContext ( "2d" ) ;
6
10
const faceDetector = new window . FaceDetector ( ) ;
7
11
const optionsInputs = document . querySelectorAll (
8
12
'.controls input[type="range"]'
@@ -17,7 +21,7 @@ function handleOption(event) {
17
21
const { value, name } = event . currentTarget ;
18
22
options [ name ] = parseFloat ( value ) ;
19
23
}
20
- optionsInputs . forEach ( input => input . addEventListener ( ' input' , handleOption ) ) ;
24
+ optionsInputs . forEach ( ( input ) => input . addEventListener ( " input" , handleOption ) ) ;
21
25
22
26
// Write a fucntion that will populate the users video
23
27
async function populateVideo ( ) {
@@ -45,7 +49,7 @@ async function detect() {
45
49
function drawFace ( face ) {
46
50
const { width, height, top, left } = face . boundingBox ;
47
51
ctx . clearRect ( 0 , 0 , canvas . width , canvas . height ) ;
48
- ctx . strokeStyle = ' #ffc600' ;
52
+ ctx . strokeStyle = " #ffc600" ;
49
53
ctx . lineWidth = 2 ;
50
54
ctx . strokeRect ( left , top , width , height ) ;
51
55
}
0 commit comments