Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit db06897

Browse files
committed
add a note about face detection not working on all systems
1 parent 957861b commit db06897

File tree

3 files changed

+24
-13
lines changed

3 files changed

+24
-13
lines changed

exercises/55 - Face Detection Censorship/pixelated-face-DEMO.js

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
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+
15
const faceDetector = new window.FaceDetector();
2-
const video = document.querySelector('video.webcam');
3-
const canvas = document.querySelector('canvas.video');
4-
const ctx = canvas.getContext('2d');
5-
const faceCanvas = document.querySelector('canvas.face');
6-
const faceCtx = faceCanvas.getContext('2d');
6+
const video = document.querySelector("video.webcam");
7+
const canvas = document.querySelector("canvas.video");
8+
const ctx = canvas.getContext("2d");
9+
const faceCanvas = document.querySelector("canvas.face");
10+
const faceCtx = faceCanvas.getContext("2d");
711
const SCALE = 1.2;
812
const SIZE = 10;
913

@@ -64,7 +68,7 @@ function censor({ boundingBox: face }) {
6468
}
6569
function drawFace(face) {
6670
const { width, height, top, left } = face.boundingBox;
67-
ctx.strokeStyle = '#ffc600';
71+
ctx.strokeStyle = "#ffc600";
6872
ctx.lineWidth = 1;
6973
ctx.strokeRect(left, top, width, height);
7074
ctx.stroke();

exercises/55 - Face Detection Censorship/pixelated-face-FINISHED.js

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
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");
610
const faceDetector = new window.FaceDetector();
711
const optionsInputs = document.querySelectorAll(
812
'.controls input[type="range"]'
@@ -17,7 +21,7 @@ function handleOption(event) {
1721
const { value, name } = event.currentTarget;
1822
options[name] = parseFloat(value);
1923
}
20-
optionsInputs.forEach(input => input.addEventListener('input', handleOption));
24+
optionsInputs.forEach((input) => input.addEventListener("input", handleOption));
2125

2226
// Write a fucntion that will populate the users video
2327
async function populateVideo() {
@@ -45,7 +49,7 @@ async function detect() {
4549
function drawFace(face) {
4650
const { width, height, top, left } = face.boundingBox;
4751
ctx.clearRect(0, 0, canvas.width, canvas.height);
48-
ctx.strokeStyle = '#ffc600';
52+
ctx.strokeStyle = "#ffc600";
4953
ctx.lineWidth = 2;
5054
ctx.strokeRect(left, top, width, height);
5155
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
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.

0 commit comments

Comments
 (0)