How to use the @google-cloud/vision.v1p1beta1 function in @google-cloud/vision

To help you get started, we’ve selected a few @google-cloud/vision examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github googleapis / nodejs-vision / samples / detect.v1p1beta1.js View on Github external
async function detectSafeSearch(fileName) {
  // [START vision_safe_search_detection]
  // Imports the Google Cloud client library
  const vision = require('@google-cloud/vision').v1p1beta1;

  // Creates a client
  const client = new vision.ImageAnnotatorClient();

  /**
   * TODO(developer): Uncomment the following line before running the sample.
   */
  // const fileName = 'Local image file, e.g. /path/to/image.png';

  // Performs safe search detection on the local file
  const [result] = await client.safeSearchDetection(fileName);
  const detections = result.safeSearchAnnotation;
  console.log('Safe search:');
  console.log(`Adult: ${detections.adult}`);
  console.log(`Medical: ${detections.medical}`);
  console.log(`Spoof: ${detections.spoof}`);