| 551 | } |
| 552 | |
| 553 | async function detectWebGeo(fileName) { |
| 554 | // [START vision_web_detection_include_geo] |
| 555 | // Imports the Google Cloud client library |
| 556 | const vision = require('@google-cloud/vision'); |
| 557 | |
| 558 | // Creates a client |
| 559 | const client = new vision.ImageAnnotatorClient(); |
| 560 | |
| 561 | /** |
| 562 | * TODO(developer): Uncomment the following line before running the sample. |
| 563 | */ |
| 564 | // const fileName = 'Local image file, e.g. /path/to/image.png'; |
| 565 | |
| 566 | const request = { |
| 567 | image: { |
| 568 | source: { |
| 569 | filename: fileName, |
| 570 | }, |
| 571 | }, |
| 572 | imageContext: { |
| 573 | webDetectionParams: { |
| 574 | includeGeoResults: true, |
| 575 | }, |
| 576 | }, |
| 577 | }; |
| 578 | |
| 579 | // Detect similar images on the web to a local file |
| 580 | const [result] = await client.webDetection(request); |
| 581 | const webDetection = result.webDetection; |
| 582 | webDetection.webEntities.forEach(entity => { |
| 583 | console.log(`Score: ${entity.score}`); |
| 584 | console.log(`Description: ${entity.description}`); |
| 585 | }); |
| 586 | // [END vision_web_detection_include_geo] |
| 587 | } |
| 588 | |
| 589 | async function detectWebGeoGCS(bucketName, fileName) { |
| 590 | // [START vision_web_detection_include_geo_gcs] |