| 15 | 'use strict'; |
| 16 | |
| 17 | async function detectFaces(fileName) { |
| 18 | // [START vision_face_detection] |
| 19 | // Imports the Google Cloud client library |
| 20 | const vision = require('@google-cloud/vision'); |
| 21 | |
| 22 | // Creates a client |
| 23 | const client = new vision.ImageAnnotatorClient(); |
| 24 | |
| 25 | /** |
| 26 | * TODO(developer): Uncomment the following line before running the sample. |
| 27 | */ |
| 28 | // const fileName = 'Local image file, e.g. /path/to/image.png'; |
| 29 | |
| 30 | const [result] = await client.faceDetection(fileName); |
| 31 | const faces = result.faceAnnotations; |
| 32 | console.log('Faces:'); |
| 33 | faces.forEach((face, i) => { |
| 34 | console.log(` Face #${i + 1}:`); |
| 35 | console.log(` Joy: ${face.joyLikelihood}`); |
| 36 | console.log(` Anger: ${face.angerLikelihood}`); |
| 37 | console.log(` Sorrow: ${face.sorrowLikelihood}`); |
| 38 | console.log(` Surprise: ${face.surpriseLikelihood}`); |
| 39 | }); |
| 40 | // [END vision_face_detection] |
| 41 | } |
| 42 | |
| 43 | async function detectFacesGCS(bucketName, fileName) { |
| 44 | // [START vision_face_detection_gcs] |