Skip to content

Latest commit

 

History

History
 
 

vision

Google Cloud Platform logo

Google Cloud Vision API Node.js Samples

The Cloud Vision API allows developers to easily integrate vision detection features within applications, including image labeling, face and landmark detection, optical character recognition (OCR), and tagging of explicit content.

Table of Contents

Setup

  1. Read Prerequisites and How to run a sample first.

  2. Install dependencies:

     npm install
    

Samples

Detection snippets

View the documentation or the source code.

Usage: node detect.js --help

Commands:
  faces <fileName>                     Detects faces in a local image file.
  faces-gcs <bucket> <fileName>        Detects faces in an image in Google Cloud Storage.
  labels <fileName>                    Detects labels in a local image file.
  labels-gcs <bucket> <fileName>       Detects labels in an image in Google Cloud Storage.
  landmarks <fileName>                 Detects landmarks in a local image file.
  landmarks-gcs <bucket> <fileName>    Detects landmarks in an image in Google Cloud Storage.
  text <fileName>                      Detects text in a local image file.
  text-gcs <bucket> <fileName>         Detects text in an image in Google Cloud Storage.
  logos <fileName>                     Detects logos in a local image file.
  logos-gcs <bucket> <fileName>        Detects logos in an image in Google Cloud Storage.
  properties <fileName>                Detects image properties in a local image file.
  properties-gcs <bucket> <fileName>   Detects image properties in an image in Google Cloud Storage.
  safe-search <fileName>               Detects safe search properties in a local image file.
  safe-search-gcs <bucket> <fileName>  Detects safe search properties in an image in Google Cloud Storage.

Options:
  --help  Show help                                                                                            [boolean]

Examples:
  node detect.js faces ./resources/face_no_surprise.jpg
  node detect.js faces-gcs my-bucket your-image.jpg
  node detect.js labels ./resources/wakeupcat.jpg
  node detect.js labels-gcs my-bucket your-image.jpg
  node detect.js landmarks ./resources/landmark.jpg
  node detect.js landmarks-gcs my-bucket your-image.jpg
  node detect.js text ./resources/wakeupcat.jpg
  node detect.js text-gcs my-bucket your-image.jpg
  node detect.js logos ./resources/logos.png
  node detect.js logos-gcs my-bucket your-image.jpg.png
  node detect.js properties ./resources/landmark.jpg
  node detect.js properties-gcs my-bucket your-image.jpg
  node detect.js safe-search ./resources/wakeupcat.jpg
  node detect.js safe-search-gcs my-bucket your-image.jpg

For more information, see https://cloud.google.com/vision/docs

Face detection tutorial

View the documentation or the source code.

This sample uses node-canvas to draw an output image. node-canvas depends on Cairo, which may require separate installation. See the node-canvas installation section for details.

Run the sample:

Usage: node faceDetection <path-to-image-file>

Example:

node faceDetection "./resources/face.png"

Text detection tutorial

View the source code.

Run the sample:

Usage: node textDetection <command> [args]...

Analyze images:

node textDetection analyze "./resources/"

Look up words:

node textDetection lookup the sunbeams in