|
14 | 14 |
|
15 | 15 | 'use strict';
|
16 | 16 |
|
17 |
| -// [START vision_quickstart] |
18 |
| -async function quickstart() { |
19 |
| - // Imports the Google Cloud client library |
20 |
| - const vision = require('@google-cloud/vision'); |
| 17 | +// sample-metadata: |
| 18 | +// title: Cloud Vision Quickstart |
| 19 | +// description: Performs label detection of an image with a cat. |
| 20 | +// usage: node quickstart.js |
21 | 21 |
|
22 |
| - // Creates a client |
23 |
| - const client = new vision.ImageAnnotatorClient(); |
| 22 | +function main() { |
| 23 | + // [START vision_quickstart] |
| 24 | + async function quickstart() { |
| 25 | + // Imports the Google Cloud client library |
| 26 | + const vision = require('@google-cloud/vision'); |
24 | 27 |
|
25 |
| - // Performs label detection on the image file |
26 |
| - const [result] = await client.labelDetection('./resources/wakeupcat.jpg'); |
27 |
| - const labels = result.labelAnnotations; |
28 |
| - console.log('Labels:'); |
29 |
| - labels.forEach(label => console.log(label.description)); |
| 28 | + // Creates a client |
| 29 | + const client = new vision.ImageAnnotatorClient(); |
| 30 | + |
| 31 | + // Performs label detection on the image file |
| 32 | + const [result] = await client.labelDetection('./resources/wakeupcat.jpg'); |
| 33 | + const labels = result.labelAnnotations; |
| 34 | + console.log('Labels:'); |
| 35 | + labels.forEach(label => console.log(label.description)); |
| 36 | + } |
| 37 | + quickstart(); |
| 38 | + // [END vision_quickstart] |
30 | 39 | }
|
31 |
| -// [END vision_quickstart] |
32 | 40 |
|
33 |
| -quickstart().catch(console.error); |
| 41 | +process.on('unhandledRejection', err => { |
| 42 | + console.error(err.message); |
| 43 | + process.exitCode = 1; |
| 44 | +}); |
| 45 | + |
| 46 | +main(...process.argv.slice(2)); |
0 commit comments