| 767 | } |
| 768 | |
| 769 | async function localizeObjectsGCS(gcsUri) { |
| 770 | // [START vision_localize_objects_gcs] |
| 771 | // Imports the Google Cloud client libraries |
| 772 | const vision = require('@google-cloud/vision'); |
| 773 | |
| 774 | // Creates a client |
| 775 | const client = new vision.ImageAnnotatorClient(); |
| 776 | |
| 777 | /** |
| 778 | * TODO(developer): Uncomment the following line before running the sample. |
| 779 | */ |
| 780 | // const gcsUri = `gs://bucket/bucketImage.png`; |
| 781 | |
| 782 | const [result] = await client.objectLocalization(gcsUri); |
| 783 | const objects = result.localizedObjectAnnotations; |
| 784 | objects.forEach(object => { |
| 785 | console.log(`Name: ${object.name}`); |
| 786 | console.log(`Confidence: ${object.score}`); |
| 787 | const veritices = object.boundingPoly.normalizedVertices; |
| 788 | veritices.forEach(v => console.log(`x: ${v.x}, y:${v.y}`)); |
| 789 | }); |
| 790 | // [END vision_localize_objects_gcs] |
| 791 | } |
| 792 | |
| 793 | require(`yargs`) // eslint-disable-line |
| 794 | .demand(1) |