MCPcopy Create free account
hub / github.com/GoogleCloudPlatform/nodejs-docs-samples / detectCropHints

Function detectCropHints

vision/detect.js:387–411  ·  view source on GitHub ↗
(fileName)

Source from the content-addressed store, hash-verified

385}
386
387async 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
413async function detectCropHintsGCS(bucketName, fileName) {
414 // [START vision_crop_hint_detection_gcs]

Callers 1

detect.jsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected