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

Function detectSafeSearch

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

Source from the content-addressed store, hash-verified

335}
336
337async function detectSafeSearch(fileName) {
338 // [START vision_safe_search_detection]
339 const vision = require('@google-cloud/vision');
340
341 // Creates a client
342 const client = new vision.ImageAnnotatorClient();
343
344 /**
345 * TODO(developer): Uncomment the following line before running the sample.
346 */
347 // const fileName = 'Local image file, e.g. /path/to/image.png';
348
349 // Performs safe search detection on the local file
350 const [result] = await client.safeSearchDetection(fileName);
351 const detections = result.safeSearchAnnotation;
352 console.log('Safe search:');
353 console.log(`Adult: ${detections.adult}`);
354 console.log(`Medical: ${detections.medical}`);
355 console.log(`Spoof: ${detections.spoof}`);
356 console.log(`Violence: ${detections.violence}`);
357 console.log(`Racy: ${detections.racy}`);
358 // [END vision_safe_search_detection]
359}
360
361async function detectSafeSearchGCS(bucketName, fileName) {
362 // [START vision_safe_search_detection_gcs]

Callers 1

detect.jsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected