| 28 | const client = new vision.ImageAnnotatorClient(); |
| 29 | |
| 30 | async function detectFaces() { |
| 31 | /** |
| 32 | * TODO(developer): Uncomment the following line before running the sample. |
| 33 | */ |
| 34 | // const fileName = 'Local image file, e.g. /path/to/image.png'; |
| 35 | |
| 36 | const [result] = await client.faceDetection(fileName); |
| 37 | const faces = result.faceAnnotations; |
| 38 | console.log('Faces:'); |
| 39 | faces.forEach((face, i) => { |
| 40 | console.log(` Face #${i + 1}:`); |
| 41 | console.log(` Joy: ${face.joyLikelihood}`); |
| 42 | console.log(` Anger: ${face.angerLikelihood}`); |
| 43 | console.log(` Sorrow: ${face.sorrowLikelihood}`); |
| 44 | console.log(` Surprise: ${face.surpriseLikelihood}`); |
| 45 | }); |
| 46 | } |
| 47 | detectFaces(); |
| 48 | // [END vision_face_detection] |
| 49 | } |