| 411 | } |
| 412 | |
| 413 | async function detectCropHintsGCS(bucketName, fileName) { |
| 414 | // [START vision_crop_hint_detection_gcs] |
| 415 | |
| 416 | // Imports the Google Cloud client libraries |
| 417 | const vision = require('@google-cloud/vision'); |
| 418 | |
| 419 | // Creates a client |
| 420 | const client = new vision.ImageAnnotatorClient(); |
| 421 | |
| 422 | /** |
| 423 | * TODO(developer): Uncomment the following lines before running the sample. |
| 424 | */ |
| 425 | // const bucketName = 'Bucket where the file resides, e.g. my-bucket'; |
| 426 | // const fileName = 'Path to file within bucket, e.g. path/to/image.png'; |
| 427 | |
| 428 | // Find crop hints for the remote file |
| 429 | const [result] = await client.cropHints(`gs://${bucketName}/${fileName}`); |
| 430 | const cropHints = result.cropHintsAnnotation; |
| 431 | cropHints.cropHints.forEach((hintBounds, hintIdx) => { |
| 432 | console.log(`Crop Hint ${hintIdx}:`); |
| 433 | hintBounds.boundingPoly.vertices.forEach((bound, boundIdx) => { |
| 434 | console.log(` Bound ${boundIdx}: (${bound.x}, ${bound.y})`); |
| 435 | }); |
| 436 | }); |
| 437 | // [END vision_crop_hint_detection_gcs] |
| 438 | } |
| 439 | |
| 440 | async function detectWeb(fileName) { |
| 441 | // [START vision_web_detection] |