microsoft-computer-vision
What is this package?
This is a wrapper package for Microsoft Computer Vision APIs, it serves as regular Node SDK due to no official one was published by Microsoft.
Table of Contents
Installation
npm install microsoft-computer-vision --save
Feature
- Promise based
- Easy function calls
- Option of using different location of API to minimize responding time
- Use new end point of {location}.api.cognitive.microsoft.com/vision instead of api.projectoxford.ai/vision
- Support all available regions from Microsoft.
Support-Regions
Pass one of the following region into request-origin
from method option.
- westus
- westus2
- eastus
- eastus2
- southcentralus
- westcentralus
- westeurope
- southeastasia
- canadacentral
- uksouth
- japaneast
- australiaeast
- brazilsouth
- centralindia
- eastasia
- northeurope
- westeurope
API
Analyze-Image
Description
This operation extracts a rich set of visual features based on the image content.
Two input methods are supported -- (1) Uploading an image binray or (2) specifying an image URL. Within your request, there is an optional parameter to allow you to choose which features to return. By default, image categories are returned in the response.
Options
"Ocp-Apim-Subscription-Key": "<your-subscription-key>" "request-origin":"<Choose-one-from-Supported-Regions>" // Required one only "visual-features":"Categories,Tags,Description,Faces,ImageType,Color,Adult" // Can be at least one or more, separated by comma "details" : "Celebrities, Landmarks" // Optional, separated by comma "language" : "en" //or "cn", if not specified, "en" by default "content-type": "application/json" "url": "image_url" //or "content-type": "application/octet-stream" "body": "image_binary"
Function call
Example of passing image by URL
microsofComputerVision
Example of passing image by binary
// Suppose you want get tag and face for /tests/image/test.jpg const microsofComputerVision = fs
Example of passing image by multipart/form-data
// here use multer as multipart/form-data handler const microsofComputerVision = const myKey = "xxxxxxxxx"const path = const express = const app = const multer = const storage = multerconst upload = app
Tag-Image
Description
This operation generates a list of words, or tags, that are relevant to the content of the supplied image. The Computer Vision API can return tags based on objects, living beings, scenery or actions found in images. Unlike categories, tags are not organized according to a hierarchical classification system, but correspond to image content. Tags may contain hints to avoid ambiguity or provide context, for example the tag "cello" may be accompanied by the hint "musical instrument". All tags are in English.
Two input methods are supported -- (1) Uploading an image binary or (2) specifying an image URL.
Options
"Ocp-Apim-Subscription-Key": "<your-subscription-key>" "request-origin":"<Choose-one-from-Supported-Regions>" // Required one only "content-type": "application/json" "url": "image_url" //or "content-type": "application/octet-stream" "body": "image_binary"
Function call
Example of passing image by URL
const microsofComputerVision = microsofComputerVision
Example of passing image by binary
// Suppose you want get tag for /tests/image/test.jpg const microsofComputerVision = fs
Example of passing image by multipart/form-data
// here use multer as multipart/form-data handler const microsofComputerVision = const myKey = "xxxxxxxxx"const path = const express = const app = const multer = const storage = multerconst upload = app
Describe-Image
Description
This operation generates a description of an image in human readable language with complete sentences. The description is based on a collection of content tags, which are also returned by the operation. More than one description can be generated for each image. Descriptions are ordered by their confidence score. All descriptions are in English.
Two input methods are supported -- (1) Uploading an image binary or (2) specifying an image URL.
Options
"Ocp-Apim-Subscription-Key": "<your-subscription-key>" "request-origin":"<Choose-one-from-Supported-Regions>" // Required one only "max-candidates":"1" // if not specified, library use 10 by default "content-type": "application/json" "url": "image_url" //or "content-type": "application/octet-stream" "body": "image_binary"
Function call
Example of passing image by URL
const microsofComputerVision = microsofComputerVision
Example of passing image by binary
// Suppose you want get description for /tests/image/test.jpg const microsofComputerVision = fs
Example of passing image by multipart/form-data
// here use multer as multipart/form-data handler const microsofComputerVision = const myKey = "xxxxxxxxx"const path = const express = const app = const multer = const storage = multerconst upload = app
Image-Thumbnail
Description
This operation generates a thumbnail image with the user-specified width and height. By default, the service analyzes the image, identifies the region of interest (ROI), and generates smart cropping coordinates based on the ROI. Smart cropping helps when you specify an aspect ratio that differs from that of the input image
A successful response contains the thumbnail image binary. If the request failed, the response contains an error code and a message to help determine what went wrong.
Options
"Ocp-Apim-Subscription-Key": "<your-subscription-key>" "request-origin":"<Choose-one-from-Supported-Regions>" // Required one only "width": "100" "height": "100" "smart-cropping": true // optional "content-type": "application/json" "url": "image_url" //or "content-type": "application/octet-stream" "body": "image_binary"
Function call
Example of passing image by URL
const microsofComputerVision = microsofComputerVision
Example of passing image by binary
// Suppose you want get a 100x100 thumbnail for /tests/image/test.jpg const microsofComputerVision = fs
Example of passing image by multipart/form-data
// here use multer as multipart/form-data handler const microsofComputerVision = const myKey = "xxxxxxxxx"const path = const express = const app = const multer = const storage = multerconst upload = app
ORC-Image
Description
Optical Character Recognition (OCR) detects text in an image and extracts the recognized characters into a machine-usable character stream.
Upon success, the OCR results will be returned.
Two input methods are supported -- (1) Uploading an image binary or (2) specifying an image URL.
Options
"Ocp-Apim-Subscription-Key": "<your-subscription-key>" "request-origin":"<Choose-one-from-Supported-Regions>" // Required one only "content-type": "application/json" "url": "image_url" "language": "{language}" // Can be one of the following // unk (AutoDetect) // zh-Hans (ChineseSimplified) // zh-Hant (ChineseTraditional) // cs (Czech) // da (Danish) // nl (Dutch) // en (English) // fi (Finnish) // fr (French) // de (German) // el (Greek) // hu (Hungarian) // it (Italian) // Ja (Japanese) // ko (Korean) // nb (Norwegian) // pl (Polish) // pt (Portuguese, // ru (Russian) // es (Spanish) // sv (Swedish) // tr (Turkish) "detect-orientation": true // optional
Function call
Example of passing image by URL
const microsofComputerVision = microsofComputerVision
Example of passing image by binary
// Suppose you want get ORC analysis for /tests/image/orcTest.jpg const microsofComputerVision = fs
Example of passing image by multipart/form-data
// here use multer as multipart/form-data handler const microsofComputerVision = const myKey = "xxxxxxxxx"const path = const express = const app = const multer = const storage = multerconst upload = app
List Domain Specific Models
Description
TThis operation returns the list of domain-specific models that are supported by the Computer Vision API. Currently, the API only supports one domain-specific model: a celebrity recognizer.
Options
"Ocp-Apim-Subscription-Key": "A_Key" "request-origin":"<Choose-one-from-Supported-Regions>" // Required one only
Function call
Example of getting List Domain Specific Models
const microsofComputerVision = microsofComputerVision
Recognize Domain Specific Content
Description
This operation recognizes content within an image by applying a domain-specific model. The list of domain-specific models that are supported by the Computer Vision API can be retrieved using the /models GET request. Currently, the API only provides a single domain-specific model: celebrities.
Two input methods are supported -- (1) Uploading an image binary or (2) specifying an image URL.
Options
"Ocp-Apim-Subscription-Key": "<your-subscription-key>" "request-origin":"<Choose-one-from-Supported-Regions>" // Required one only "content-type": "application/json" "url": "image_url" "model": "{model}" // use listDomainSpecificModels() to get current available models
Function call
Example of passing image by URL
const microsofComputerVision = microsofComputerVision
Example of passing image by binary
// Suppose you want get model in /tests/image/RDSCTest.jpg const microsofComputerVision = fs
Example of passing image by multipart/form-data
// here use multer as multipart/form-data handler const microsofComputerVision = const myKey = "xxxxxxxxx"const path = const express = const app = const multer = const storage = multerconst upload = app
License
This library is licensed under MIT. Full license text is available in COPYING.
Contributing
See CONTRIBUTING.