npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

node-cloud-vision-api-comoc

v0.1.2

Published

Node client for Google Cloud Vision API

Downloads

3

Readme

Node Cloud Vision API

node-cloud-vision-api-comoc is a node client wrapper for Cloud Vision API.

Cloud Vision API Docs https://cloud.google.com/vision/docs/

Note that currently only limited preview for alpha-test users.

Supported features

Feature Type | Description ------------- | ------------- FACE_DETECTION | Run face detection LANDMARK_DETECTION | Run models to execute landmark detection LOGO_DETECTION | Run models to execute product logo detection LABEL_DETECTION | Run models to execute Image Content Analysis TEXT_DETECTION | Run models to execute OCR on an image SAFE_SEARCH_DETECTION | Run models to compute image safe search properties

Difference between this version and the original version: tejitak/node-cloud-vision-api

  • v1(not v1alpha1) API compliant
  • Base64 encoded image input avalilable

Setup

Preparation

  • Sign up limited preview for Cloud Vision API https://cloud.google.com/vision/
  • Cloud Vision API Key is needed

Install

npm install node-cloud-vision-api-comoc --save

Auth

API requests on node-cloud-vision-api-comoc is internally managed by google-api-nodejs-client

You can setup auth data with the following samples

  • Use Server Key
const vision = require('node-cloud-vision-api-comoc')
vision.init({auth: 'YOUR_API_KEY'})
  • Use OAuth
const vision = require('node-cloud-vision-api-comoc')
const google = require('googleapis')
const oauth2Client = new google.auth.OAuth2('YOUR_GOOGLE_OAUTH_CLIENT_ID', 'YOUR_GOOGLE_OAUTH_SECRET', 'YOUR_GOOGLE_OAUTH_CALLBACK_URL')
oauth2Client.setCredentials({refresh_token: 'YOUR_GOOGLE_OAUTH_REFRESH_TOKEN'})
vision.init({auth: oauth2Client})

Sample

'use strict'
const vision = require('node-cloud-vision-api-comoc')

// init with auth
vision.init({auth: 'YOUR_API_KEY'})

// construct parameters
const req = new vision.Request({
  image: new vision.Image('/Users/tejitak/temp/test1.jpg'),
  features: [
    new vision.Feature('FACE_DETECTION', 4),
    new vision.Feature('LABEL_DETECTION', 10),
  ]
})

// send single request
vision.annotate(req).then((res) => {
  // handling response
  console.log(JSON.stringify(res.responses))
}, (e) => {
  console.log('Error: ', e)
})

See more in test_annotate.js

Remote image file sample

Image files on web can be specified with 'url' paramters in Image object

const req = new vision.Request({
  image: new vision.Image({
    url: 'https://scontent-nrt1-1.cdninstagram.com/hphotos-xap1/t51.2885-15/e35/12353236_1220803437936662_68557852_n.jpg'
  }),
  features: [
    new vision.Feature('FACE_DETECTION', 1),
    new vision.Feature('LABEL_DETECTION', 10),
  ]
})

See more in test_annotate_remote.js

Multiple Requests per API call

// construct parameters
// 1st image of request is load from local
const req1 = new vision.Request({
  image: new vision.Image({
    path: '/Users/tejitak/temp/test1.jpg'
  }),
  features: [
    new vision.Feature('FACE_DETECTION', 4),
    new vision.Feature('LABEL_DETECTION', 10),
  ]
})

// 2nd image of request is load from Web
const req2 = new vision.Request({
  image: new vision.Image({
    url: 'https://scontent-nrt1-1.cdninstagram.com/hphotos-xap1/t51.2885-15/e35/12353236_1220803437936662_68557852_n.jpg'
  }),
  features: [
    new vision.Feature('FACE_DETECTION', 1),
    new vision.Feature('LABEL_DETECTION', 10),
  ]
})

// send multi requests by one API call
vision.annotate([req1, req2]).then((res) => {
  // handling response for each request
  console.log(JSON.stringify(res.responses))
}, (e) => {
  console.log('Error: ', e)
})

See more in test_annotate_remote.js

Base64 encoded image sample

Base64 enocded image data can be specified with 'base64' paramters in Image object

const req = new vision.Request({
  image: new vision.Image({
    base64: '/9j/4AAQSkZJRgABAQ...' // someting like this
  }),
  features: [
    new vision.Feature('FACE_DETECTION', 1),
    new vision.Feature('LABEL_DETECTION', 10),
  ]
})

Supported Node Version

Recommended node version is above v4.0.0 because this module is implemented with ES6.