| 385 | } |
| 386 | |
| 387 | async function detectCropHints(fileName) { |
| 388 | // [START vision_crop_hint_detection] |
| 389 | |
| 390 | // Imports the Google Cloud client library |
| 391 | const vision = require('@google-cloud/vision'); |
| 392 | |
| 393 | // Creates a client |
| 394 | const client = new vision.ImageAnnotatorClient(); |
| 395 | |
| 396 | /** |
| 397 | * TODO(developer): Uncomment the following line before running the sample. |
| 398 | */ |
| 399 | // const fileName = 'Local image file, e.g. /path/to/image.png'; |
| 400 | |
| 401 | // Find crop hints for the local file |
| 402 | const [result] = await client.cropHints(fileName); |
| 403 | const cropHints = result.cropHintsAnnotation; |
| 404 | cropHints.cropHints.forEach((hintBounds, hintIdx) => { |
| 405 | console.log(`Crop Hint ${hintIdx}:`); |
| 406 | hintBounds.boundingPoly.vertices.forEach((bound, boundIdx) => { |
| 407 | console.log(` Bound ${boundIdx}: (${bound.x}, ${bound.y})`); |
| 408 | }); |
| 409 | }); |
| 410 | // [END vision_crop_hint_detection] |
| 411 | } |
| 412 | |
| 413 | async function detectCropHintsGCS(bucketName, fileName) { |
| 414 | // [START vision_crop_hint_detection_gcs] |