Socket
Socket
Sign inDemoInstall

azure-cognitiveservices-vision

Package Overview
Dependencies
71
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    azure-cognitiveservices-vision

Microsoft Azure Cognitive Services Vision API Client Library for Node.js


Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Created
Weekly downloads
 

Changelog

Source

2017.04.03 version 2.0.0-preview

  • Updated type definition (.d.ts) files for all the packages and improved typescript support.
  • Added Promise support for all the APIs. For each callback based API, we now have an overloaded method that returns a Promise.
  • Moved Javascript code to ES6 syntax.
  • Minimum required node.js version is 6.10
  • Added a new vscode extension named Azure Node Essentials to help you easily interact with Azure.
  • Improved the loading time of rollup azure package
  • Added client libraries for following ARM services
  • Runtime (ms-rest and ms-rest-azure)
    • Updated d.ts files for ms-rest and ms-rest-azure
    • All the login methods (interactiveLogin, loginWithServicePrincipalSecret, loginWithUsernamePassword) now support callbacks as well as Promises.
    • Added support to send (a generic request, or a generic long running request (that polls)) using the authenticated base client in the runtime

Readme

Source

Microsoft Azure SDK for Node.js - Cognitive Services Vision

This project provides a Node.js rollup package that makes it easy to work with the Microsoft Azure Cognitive Services Vision APIs. Right now it supports:

  • Node.js version: 6.x or higher

How to Install

npm install azure-cognitiveservices-vision

How to use

Create a Cognitive Services Account(ex. Computer Vision)

  const msRestAzure = require('ms-rest-azure');
  const CognitiveServicesManagement = require("azure-arm-cognitiveservices");
  let client;
  let createAccount = msRestAzure.interactiveLogin().then((credentials) => {
    client = new CognitiveServicesManagement(credentials, suite.subscriptionId);
    return client.accounts.create('groupname', 'accountname', {
      sku: {
        name: "F0"
      },
      kind: "ComputerVision",
      location: "westus",
      properties: {}
    });
  }).catch((err) => {
    console.log('An error ocurred');
    console.dir(err, {depth: null, colors: true});
  });

List the keys from the created account

  let serviceKey;
  createAccount.then((result) => {
    return client.accounts.listKeys('groupname', 'accountname');
  }).then((result) => {
    serviceKey = result.key1;
    console.log(result.key2);
  }).catch((err) => {
    console.log('An error ocurred');
    console.dir(err, {depth: null, colors: true});
  });

Create credentials

const CognitiveServicesCredentials = require('ms-rest-azure').CognitiveServicesCredentials;

// Creating the Cognitive Services credentials
// This requires a key corresponding to the service being used (i.e. text-analytics, etc)
let credentials = new CognitiveServicesCredentials(serviceKey);

Computer Vision API

const vision = require('azure-cognitiveservices-vision');

let client = new vision.ComputerVisionAPIClient(credentials);
let fileStream = fs.createReadStream('pathToSomeImage.jpg');
client.analyzeImageInStreamWithHttpOperationResponse(fileStream, {
  visualFeatures: ["Categories", "Tags", "Description"]
}).then((response) => {
  console.log(response.body.tags);
  console.log(response.body.description.captions[0]);
}).catch((err) => {
  throw err;
});

Face API

let fileStream = fs.createReadStream('pathToSomeImage.jpg');
client.face.detectInStreamWithHttpOperationResponse(fileStream, {
  returnFaceId: true,
  returnFaceAttributes: 'age,gender,headPose,smile,facialHair,glasses,emotion,hair,makeup,occlusion,accessories,exposure,noise'
}).then((httpResponse) => {
  console.log(httpResponse.response.body);
}).catch((err) => {
  throw err;
});

More Detailed Information

https://azure.microsoft.com/en-us/try/cognitive-services/ under "Vision"

Keywords

FAQs

Last updated on 26 Nov 2018

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc