| 335 | } |
| 336 | |
| 337 | async 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 | |
| 361 | async function detectSafeSearchGCS(bucketName, fileName) { |
| 362 | // [START vision_safe_search_detection_gcs] |