| 41 | } |
| 42 | |
| 43 | async function detectFacesGCS(bucketName, fileName) { |
| 44 | // [START vision_face_detection_gcs] |
| 45 | // Imports the Google Cloud client libraries |
| 46 | const vision = require('@google-cloud/vision'); |
| 47 | |
| 48 | // Creates a client |
| 49 | const client = new vision.ImageAnnotatorClient(); |
| 50 | |
| 51 | /** |
| 52 | * TODO(developer): Uncomment the following lines before running the sample. |
| 53 | */ |
| 54 | // const bucketName = 'Bucket where the file resides, e.g. my-bucket'; |
| 55 | // const fileName = 'Path to file within bucket, e.g. path/to/image.png'; |
| 56 | |
| 57 | // Performs face detection on the gcs file |
| 58 | const [result] = await client.faceDetection(`gs://${bucketName}/${fileName}`); |
| 59 | const faces = result.faceAnnotations; |
| 60 | console.log('Faces:'); |
| 61 | faces.forEach((face, i) => { |
| 62 | console.log(` Face #${i + 1}:`); |
| 63 | console.log(` Joy: ${face.joyLikelihood}`); |
| 64 | console.log(` Anger: ${face.angerLikelihood}`); |
| 65 | console.log(` Sorrow: ${face.sorrowLikelihood}`); |
| 66 | console.log(` Surprise: ${face.surpriseLikelihood}`); |
| 67 | }); |
| 68 | // [END vision_face_detection_gcs] |
| 69 | } |
| 70 | |
| 71 | async function detectLabels(fileName) { |
| 72 | // [START vision_label_detection] |