How to use the @google-cloud/vision.v1p1beta1.ImageAnnotatorClient 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}`);
  console.log(`Violence: ${detections.violence}`);
  console.log(`Racy: ${detections.racy}`);
  // [END vision_safe_search_detection]
github googleapis / nodejs-vision / samples / detect.v1p1beta1.js View on Github external
async function detectFulltext(fileName) {
  // [START vision_detect_document]
  // Imports the Google Cloud client libraries
  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 label detection on the local file
  const [result] = await client.textDetection(fileName);
  const pages = result.fullTextAnnotation.pages;
  pages.forEach(page => {
    page.blocks.forEach(block => {
      const blockWords = [];
      block.paragraphs.forEach(paragraph => {
        paragraph.words.forEach(word => blockWords.push(word));
        console.log(`Paragraph confidence: ${paragraph.confidence}`);
      });
github googleapis / nodejs-vision / samples / detect.v1p1beta1.js View on Github external
async function detectWeb(fileName) {
  // [START vision_web_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';

  // Detect similar images on the web to a local file
  const [result] = await client.webDetection(fileName);
  const webDetection = result.webDetection;
  if (webDetection.bestGuessLabels.length) {
    webDetection.bestGuessLabels.forEach(label => {
      console.log(`Best guess label: ${label.label}`);
    });
  }

  if (webDetection.pagesWithMatchingImages.length) {
github googleapis / nodejs-vision / samples / detect.v1p1beta1.js View on Github external
async function detectWebEntitiesIncludingGeoResults(fileName) {
  // [START vision_web_entities_include_geo_results]
  // 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';

  const request = {
    image: {
      source: {
        filename: fileName,
      },
    },
    imageContext: {
      webDetectionParams: {
        includeGeoResults: true,
      },