MCPcopy Create free account
hub / github.com/GoogleCloudPlatform/nodejs-docs-samples / detectFacesGCS

Function detectFacesGCS

vision/detect.js:43–69  ·  view source on GitHub ↗
(bucketName, fileName)

Source from the content-addressed store, hash-verified

41}
42
43async 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
71async function detectLabels(fileName) {
72 // [START vision_label_detection]

Callers 1

detect.jsFile · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected