| 90 | } |
| 91 | |
| 92 | async function detectLabelsGCS(bucketName, fileName) { |
| 93 | // [START vision_label_detection_gcs] |
| 94 | // Imports the Google Cloud client libraries |
| 95 | const vision = require('@google-cloud/vision'); |
| 96 | |
| 97 | // Creates a client |
| 98 | const client = new vision.ImageAnnotatorClient(); |
| 99 | |
| 100 | /** |
| 101 | * TODO(developer): Uncomment the following lines before running the sample. |
| 102 | */ |
| 103 | // const bucketName = 'Bucket where the file resides, e.g. my-bucket'; |
| 104 | // const fileName = 'Path to file within bucket, e.g. path/to/image.png'; |
| 105 | |
| 106 | // Performs label detection on the gcs file |
| 107 | const [result] = await client.labelDetection( |
| 108 | `gs://${bucketName}/${fileName}` |
| 109 | ); |
| 110 | const labels = result.labelAnnotations; |
| 111 | console.log('Labels:'); |
| 112 | labels.forEach(label => console.log(label.description)); |
| 113 | // [END vision_label_detection_gcs] |
| 114 | } |
| 115 | |
| 116 | async function detectLandmarks(fileName) { |
| 117 | // [START vision_landmark_detection] |