How to Upload Binary Image to Microsoft Vision Api

microsoft-computer-vision

npm version GitHub issues GitHub stars GitHub forks HitCount Build Status NSP Status GitHub license Build status

NPM

What is this package?

This is a wrapper package for Microsoft Reckoner Vision APIs, information technology serves as regular Node SDK due to no official one was published by Microsoft.


Table of Contents

  • Installation

  • Characteristic

  • Back up Region

  • API

    • Analyze-Prototype
    • Tag-Epitome
    • Describe-Image
    • Paradigm-Thumbnail
    • ORC-Image
    • Listing Domain Specific Models
    • Recognize Domain Specific Content
  • License

  • Contributing

Installation

npm install microsoft-reckoner-vision --relieve

Feature

  • Promise based
  • Piece of cake function calls
  • Option of using different location of API to minimize responding time
  • Use new cease point of {location}.api.cerebral.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

Clarify-Image


Clarification

This operation extracts a rich set of visual features based on the image content.

Two input methods are supported -- (i) Uploading an image binray or (ii) specifying an image URL. Within your asking, there is an optional parameter to allow y'all to choose which features to return. By default, paradigm categories are returned in the response.


Options

              {              "Ocp-Apim-Subscription-Primal":              "<your-subscription-key>"              ,              "asking-origin":"<Choose-1-from-Supported-Regions>"              ,              // Required ane simply              "visual-features":"Categories,Tags,Clarification,Faces,ImageType,Color,Adult"              ,              // Tin can exist 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-blazon":              "application/json"              ,              "url":              "image_url"              //or              "content-type":              "awarding/octet-stream"              ,              "body":              "image_binary"              }            

Function phone call

              analyzeImage              (              {              "Ocp-Apim-Subscription-Central":              "<your-subscription-key>"              ,              "request-origin":"<Choose-ane-from-Supported-Regions>"              ,              "visual-features":"Tags, Faces, (...)"              ,              "content-type":              "content type"              ,              "url":              "image_url"              //or "body": "image_binary"              }              )              .              so              (              (              issue              )              =>              {              // the tags are now in the upshot              }              )              .              catch              (              (              err              )              =>              {              throw              err              }              )            

Instance of passing prototype by URL

              microsofComputerVision              .              analyzeImage              (              {              "Ocp-Apim-Subscription-Primal":              "<your-subscription-central>"              ,              "request-origin":"<Cull-one-from-Supported-Regions>"              ,              "content-type":              "application/json"              ,              "url":              "https://goo.gl/Hpz7gi"              ,              "visual-features":"Tags, Faces"              }              )              .              then              (              (              outcome              )              =>              {              panel              .              log              (              result              )              // { tags:              //  [ { proper name: 'tree', conviction: 0.9994124174118042 },              //    { name: 'outdoor', conviction: 0.9984000325202942 },              //    { name: 'sky', confidence: 0.9974111914634705 },              //    { name: 'grass', confidence: 0.9564579725265503 },              //    { name: 'building', confidence: 0.9447041153907776 },              //    { name: 'castle', confidence: 0.6080892086029053 } ],              // requestId: 'c9c33a0d-7100-4cea-b37a-b93d2b3aff10',              // metadata: { width: 883, height: 589, format: 'Jpeg' },              // faces: [] }              }              )              .              grab              (              (              err              )              =>              {              throw              err              }              )            

Instance of passing image by binary

              // Suppose you desire get tag and face for /tests/paradigm/exam.jpg              const              microsofComputerVision              =              require              (              "microsoft-computer-vision"              )              fs              .              readFile              (              './tests/paradigm/exam.jpg'              ,              function              (              err              ,              data              )              {              if              (              err              )              throw              err              microsofComputerVision              .              analyzeImage              (              {              "Ocp-Apim-Subscription-Primal":              "<your-subscription-primal>"              ,              "request-origin":"<Choose-one-from-Supported-Regions>"              ,              "content-type":              "awarding/octet-stream"              ,              "body":              data              ,              "visual-features":"Tags, Faces"              }              )              .              and so              (              (              upshot              )              =>              {              console              .              log              (              consequence              )              // { tags:              //  [ { name: 'tree', confidence: 0.9994124174118042 },              //    { proper noun: 'outdoor', confidence: 0.9984000325202942 },              //    { name: 'heaven', conviction: 0.9974111914634705 },              //    { proper noun: 'grass', confidence: 0.9564579725265503 },              //    { name: 'building', confidence: 0.9447041153907776 },              //    { proper name: 'castle', confidence: 0.6080892086029053 } ],              // requestId: 'c9c33a0d-7100-4cea-b37a-b93d2b3aff10',              // metadata: { width: 883, meridian: 589, format: 'Jpeg' },              // faces: [] }              }              )              .              grab              (              (              err              )              =>              {              throw              err              }              )              }              )            

Example of passing image past multipart/form-data

              // here use multer equally multipart/class-data handler              const              microsofComputerVision              =              require              (              "microsoft-figurer-vision"              )              const              myKey              =              "xxxxxxxxx"              const              path              =              require              (              'path'              )              const              limited              =              crave              (              'express'              )              const              app              =              express              (              )              const              multer              =              require              (              'multer'              )              const              storage              =              multer              .              memoryStorage              (              )              const              upload              =              multer              (              {              storage:              storage              }              )              .              single              (              'paradigm'              )              app              .              post              (              '/upload'              ,              (              req              ,              res              ,              next              )              =>              {              upload              (              req              ,              res              ,              part              (              err              )              {              if              (              err              )              {              // An error occurred when uploading              console              .              log              (              err              )              render              }              // Everything went fine              microsofComputerVision              .              analyzeImage              (              {              "Ocp-Apim-Subscription-Key":              myKey              ,              "content-type":              "multipart/course-information"              ,              "trunk":              req              .              file              ,              "visual-features":"Tags, Faces"              ,              "request-origin":"westus"              }              )              .              then              (              (              result              )              =>              {              // do stuff with effect              }              )              .              grab              (              (              err              )              =>              {              throw              err              }              )              }              )              }              )            

Tag-Prototype


Description

This operation generates a list of words, or tags, that are relevant to the content of the supplied image. The Figurer Vision API can return tags based on objects, living beings, scenery or actions establish in images. Unlike categories, tags are not organized according to a hierarchical classification system, merely correspond to paradigm content. Tags may comprise hints to avoid ambiguity or provide context, for example the tag "cello" may be accompanied past the hint "musical musical instrument". All tags are in English.

Two input methods are supported -- (one) Uploading an paradigm binary or (2) specifying an prototype URL.


Options

              {              "Ocp-Apim-Subscription-Key":              "<your-subscription-key>"              ,              "request-origin":"<Choose-one-from-Supported-Regions>"              ,              // Required one only              "content-blazon":              "application/json"              ,              "url":              "image_url"              //or              "content-type":              "application/octet-stream"              ,              "body":              "image_binary"              }            

Function telephone call

              tagImage              (              {              "Ocp-Apim-Subscription-Key":              "<your-subscription-key>"              ,              "request-origin":"<Choose-one-from-Supported-Regions>"              ,              "content-type":              "content type"              ,              "url":              "image_url"              //or "body": "image_binary"              }              )              .              and then              (              (              event              )              =>              {              // the tags are now in the result              }              )              .              catch              (              (              err              )              =>              {              throw              err              }              )            

Example of passing image by URL

              const              microsofComputerVision              =              require              (              "microsoft-computer-vision"              )              microsofComputerVision              .              tagImage              (              {              "Ocp-Apim-Subscription-Cardinal":              "<your-subscription-cardinal>"              ,              "request-origin":"<Choose-one-from-Supported-Regions>"              ,              "content-type":              "awarding/json"              ,              "url":              "https://goo.gl/Hpz7gi"              }              )              .              and so              (              (              result              )              =>              {              console              .              log              (              result              )              // { tags:              //  [ { proper name: 'tree', conviction: 0.9994124174118042 },              //    { name: 'outdoor', conviction: 0.9984000325202942 },              //    { name: 'heaven', confidence: 0.9974111914634705 },              //    { name: 'grass', confidence: 0.9564579725265503 },              //    { proper name: 'building', confidence: 0.9447041153907776 },              //    { proper noun: 'castle', confidence: 0.6080892086029053 } ],              // requestId: 'eaafdbce-fa0f-4395-9aa3-f09a6d8e1a62',              // metadata: { width: 883, pinnacle: 589, format: 'Jpeg' } }              }              )              .              catch              (              (              err              )              =>              {              throw              err              }              )            

Example of passing image past binary

              // Suppose you lot want go tag for /tests/paradigm/test.jpg              const              microsofComputerVision              =              require              (              "microsoft-reckoner-vision"              )              fs              .              readFile              (              './tests/paradigm/test.jpg'              ,              role              (              err              ,              data              )              {              microsofComputerVision              .              tagImage              (              {              "Ocp-Apim-Subscription-Cardinal":              "<your-subscription-key>"              ,              "request-origin":"<Cull-one-from-Supported-Regions>"              ,              "content-blazon":              "application/octet-stream"              ,              "torso":              data              }              )              .              then              (              (              result              )              =>              {              console              .              log              (              result              )              // { tags:              //  [ { name: 'tree', confidence: 0.9994124174118042 },              //    { name: 'outdoor', confidence: 0.9984000325202942 },              //    { name: 'heaven', conviction: 0.9974111914634705 },              //    { proper noun: 'grass', conviction: 0.9564579725265503 },              //    { name: 'edifice', conviction: 0.9447041153907776 },              //    { proper noun: 'castle', confidence: 0.6080892086029053 } ],              // requestId: 'eaafdbce-fa0f-4395-9aa3-f09a6d8e1a62',              // metadata: { width: 883, top: 589, format: 'Jpeg' } }              }              )              .              take hold of              (              (              err              )              =>              {              throw              err              }              )              }              )            

Example of passing prototype by multipart/course-data

              // here use multer every bit multipart/form-data handler              const              microsofComputerVision              =              crave              (              "microsoft-computer-vision"              )              const              myKey              =              "xxxxxxxxx"              const              path              =              require              (              'path'              )              const              limited              =              crave              (              'limited'              )              const              app              =              express              (              )              const              multer              =              require              (              'multer'              )              const              storage              =              multer              .              memoryStorage              (              )              const              upload              =              multer              (              {              storage:              storage              }              )              .              single              (              'image'              )              app              .              mail service              (              '/upload'              ,              (              req              ,              res              ,              next              )              =>              {              upload              (              req              ,              res              ,              function              (              err              )              {              if              (              err              )              {              // An mistake occurred when uploading              panel              .              log              (              err              )              render              }              // Everything went fine              microsofComputerVision              .              tagImage              (              {              "Ocp-Apim-Subscription-Key":              myKey              ,              "content-type":              "multipart/class-information"              ,              "body":              req              .              file              ,              "asking-origin":"westus"              }              )              .              then              (              (              result              )              =>              {              // do stuff with event              }              )              .              grab              (              (              err              )              =>              {              throw              err              }              )              }              )              }              )            

Describe-Image


Description

This operation generates a description of an image in human readable linguistic communication with complete sentences. The description is based on a collection of content tags, which are also returned by the operation. More one description tin be generated for each paradigm. Descriptions are ordered by their confidence score. All descriptions are in English.

Two input methods are supported -- (1) Uploading an prototype binary or (2) specifying an prototype URL.


Options

              {              "Ocp-Apim-Subscription-Key":              "<your-subscription-primal>"              ,              "asking-origin":"<Cull-i-from-Supported-Regions>"              ,              // Required 1 only              "max-candidates":"ane"              ,              // if not specified, library employ x by default              "content-type":              "awarding/json"              ,              "url":              "image_url"              //or              "content-type":              "application/octet-stream"              ,              "torso":              "image_binary"              }            

Function call

              describeImage              (              {              "Ocp-Apim-Subscription-Primal":              "<your-subscription-key>"              ,              "request-origin":"<Choose-i-from-Supported-Regions>"              ,              "max-candidates":"1"              ,              "content-type":              "content type"              ,              "url":              "image_url"              //or "body": "image_binary"              }              )              .              and so              (              (              issue              )              =>              {              // the tags are now in the result              }              )              .              grab              (              (              err              )              =>              {              throw              err              }              )            

Example of passing image by URL

              const              microsofComputerVision              =              crave              (              "microsoft-computer-vision"              )              microsofComputerVision              .              describeImage              (              {              "Ocp-Apim-Subscription-Key":              "<your-subscription-key>"              ,              "request-origin":"<Choose-i-from-Supported-Regions>"              ,              "max-candidates":"ane"              ,              "content-type":              "application/json"              ,              "url":              "https://goo.gl/Hpz7gi"              }              )              .              then              (              (              issue              )              =>              {              console              .              log              (              result              )              // {              // "description": {              //     "tags": [              //         "outdoor",              //         "grass",              //         "building",              //         "large",              //         "forepart",              //          ...              //     ],              //     "captions": [              //         {              //             "text": "a castle with a clock tower in forepart of a building",              //             "confidence": 0.5546771291117777              //         },              //         {              //             "text": "a castle with a clock tower",              //             "confidence": 0.5470764456423322              //         }              //     ]              // },              // "requestId": "b8ded71f-d515-41d4-9ac2-39372c41b3d8",              // "metadata": {              //     "width": 883,              //     "meridian": 589,              //     "format": "Jpeg"              // }              }              )              .              catch              (              (              err              )              =>              {              throw              err              }              )            

Case of passing epitome by binary

              // Suppose yous want become description for /tests/image/test.jpg              const              microsofComputerVision              =              require              (              "microsoft-computer-vision"              )              fs              .              readFile              (              './tests/paradigm/test.jpg'              ,              function              (              err              ,              data              )              {              microsofComputerVision              .              describeImage              (              {              "Ocp-Apim-Subscription-Key":              "<your-subscription-key>"              ,              "request-origin":"<Cull-ane-from-Supported-Regions>"              ,              "max-candidates":"one"              ,              "content-blazon":              "awarding/octet-stream"              ,              "body":              data              }              )              .              then              (              (              result              )              =>              {              panel              .              log              (              consequence              )              // {              // "description": {              //     "tags": [              //         "outdoor",              //         "grass",              //         "building",              //         "large",              //         "front",              //          ...              //     ],              //     "captions": [              //         {              //             "text": "a castle with a clock tower in front of a building",              //             "confidence": 0.5546771291117777              //         },              //         {              //             "text": "a castle with a clock tower",              //             "conviction": 0.5470764456423322              //         }              //     ]              // },              // "requestId": "b8ded71f-d515-41d4-9ac2-39372c41b3d8",              // "metadata": {              //     "width": 883,              //     "superlative": 589,              //     "format": "Jpeg"              // }              }              }              )              .              take hold of              (              (              err              )              =>              {              throw              err              }              )              }              )            

Instance of passing prototype by multipart/class-data

              // here employ multer as multipart/form-data handler              const              microsofComputerVision              =              require              (              "microsoft-estimator-vision"              )              const              myKey              =              "xxxxxxxxx"              const              path              =              require              (              'path'              )              const              express              =              require              (              'express'              )              const              app              =              express              (              )              const              multer              =              require              (              'multer'              )              const              storage              =              multer              .              memoryStorage              (              )              const              upload              =              multer              (              {              storage:              storage              }              )              .              single              (              'epitome'              )              app              .              post              (              '/upload'              ,              (              req              ,              res              ,              side by side              )              =>              {              upload              (              req              ,              res              ,              function              (              err              )              {              if              (              err              )              {              // An error occurred when uploading              console              .              log              (              err              )              return              }              // Everything went fine              microsofComputerVision              .              describeImage              (              {              "Ocp-Apim-Subscription-Central":              myKey              ,              "content-type":              "multipart/form-information"              ,              "max-candidates":"1"              ,              "body":              req              .              file              ,              "asking-origin":"westus"              }              )              .              then              (              (              event              )              =>              {              // exercise stuff with result              }              )              .              catch              (              (              err              )              =>              {              throw              err              }              )              }              )              }              )            

Image-Thumbnail


Description

This operation generates a thumbnail image with the user-specified width and acme. By default, the service analyzes the image, identifies the region of involvement (ROI), and generates smart cropping coordinates based on the ROI. Smart cropping helps when yous specify an attribute ratio that differs from that of the input image

A successful response contains the thumbnail paradigm binary. If the request failed, the response contains an error code and a message to help determine what went incorrect.


Options

              {              "Ocp-Apim-Subscription-Central":              "<your-subscription-key>"              ,              "request-origin":"<Choose-one-from-Supported-Regions>"              ,              // Required i only              "width":              "100"              ,              "tiptop":              "100"              ,              "smart-cropping":              truthful              // optional              "content-blazon":              "application/json"              ,              "url":              "image_url"              //or              "content-blazon":              "application/octet-stream"              ,              "body":              "image_binary"              }            

Function call

              imageThumbnail              (              {              "Ocp-Apim-Subscription-Key":              "<your-subscription-key>"              ,              "request-origin":"<Choose-one-from-Supported-Regions>"              ,              "width":              "100"              ,              "height":              "100"              ,              "smart-cropping":              truthful              "content-type":              "content type"              ,              "url":              "image_url"              //or "trunk": "image_binary"              }              )              .              and so              (              (              result              )              =>              {              // the tags are now in the result              }              )              .              grab              (              (              err              )              =>              {              throw              err              }              )            

Instance of passing image by URL

              const              microsofComputerVision              =              require              (              "microsoft-computer-vision"              )              microsofComputerVision              .              imageThumbnail              (              {              "Ocp-Apim-Subscription-Key":              "<your-subscription-cardinal>"              ,              "asking-origin":"<Choose-one-from-Supported-Regions>"              ,              "width":              "100"              ,              "tiptop":              "100"              ,              "smart-cropping":              true              "content-type":              "application/json"              ,              "url":              "https://goo.gl/Hpz7gi"              }              )              .              and then              (              (              thumbnailBinary              )              =>              {              // Exercise something to the binary              fs              .              writeFile              (              '/thumbnail.jpg'              ,              thumbnailBinary              ,              'binary'              ,              office              (              err              )              {              if              (              err              )              throw              err              }              )              }              )              .              grab              (              (              err              )              =>              {              throw              err              }              )            

Example of passing image by binary

              // Suppose y'all want get a 100x100 thumbnail for /tests/image/test.jpg              const              microsofComputerVision              =              crave              (              "microsoft-computer-vision"              )              fs              .              readFile              (              './tests/paradigm/examination.jpg'              ,              part              (              err              ,              information              )              {              microsofComputerVision              .              imageThumbnail              (              {              "Ocp-Apim-Subscription-Key":              "<your-subscription-key>"              ,              "request-origin":"<Choose-one-from-Supported-Regions>"              ,              "width":              "100"              ,              "height":              "100"              ,              "smart-cropping":              true              "content-type":              "application/octet-stream"              ,              "body":              information              }              )              .              and so              (              (              thumbnailBinary              )              =>              {              // Practice something to the binary              fs              .              writeFile              (              '/thumbnail.jpg'              ,              thumbnailBinary              ,              'binary'              ,              part              (              err              )              {              if              (              err              )              throw              err              }              )              }              }              )              .              catch              (              (              err              )              =>              {              throw              err              }              )              }              )            

Example of passing image by multipart/form-data

              // here use multer every bit multipart/class-information handler              const              microsofComputerVision              =              require              (              "microsoft-reckoner-vision"              )              const              myKey              =              "xxxxxxxxx"              const              path              =              require              (              'path'              )              const              limited              =              require              (              'express'              )              const              app              =              limited              (              )              const              multer              =              require              (              'multer'              )              const              storage              =              multer              .              memoryStorage              (              )              const              upload              =              multer              (              {              storage:              storage              }              )              .              single              (              'paradigm'              )              app              .              post              (              '/upload'              ,              (              req              ,              res              ,              next              )              =>              {              upload              (              req              ,              res              ,              part              (              err              )              {              if              (              err              )              {              // An error occurred when uploading              console              .              log              (              err              )              return              }              // Everything went fine              microsofComputerVision              .              imageThumbnail              (              {              "Ocp-Apim-Subscription-Key":              myKey              ,              "content-type":              "multipart/grade-data"              ,              "width":              "100"              ,              "height":              "100"              ,              "smart-cropping":              truthful              ,              "body":              req              .              file              ,              "request-origin":"westus"              }              )              .              then              (              (              result              )              =>              {              // do stuff with issue              }              )              .              grab              (              (              err              )              =>              {              throw              err              }              )              }              )              }              )            

ORC-Image


Description

Optical Grapheme Recognition (OCR) detects text in an image and extracts the recognized characters into a machine-usable grapheme stream.

Upon success, the OCR results will be returned.

Two input methods are supported -- (i) Uploading an prototype binary or (ii) specifying an image URL.


Options

              {              "Ocp-Apim-Subscription-Central":              "<your-subscription-key>"              ,              "request-origin":"<Choose-ane-from-Supported-Regions>"              ,              // Required one only              "content-blazon":              "application/json"              ,              "url":              "image_url"              ,              "language":              "{language}"              ,              // Tin be 1 of the post-obit              // unk (AutoDetect)              // zh-Hans (ChineseSimplified)              // zh-Hant (ChineseTraditional)              // cs (Czech)              // da (Danish)              // nl (Dutch)              // en (English)              // fi (Finnish)              // fr (French)              // de (German language)              // el (Greek)              // hu (Hungarian)              // information technology (Italian)              // Ja (Japanese)              // ko (Korean)              // nb (Norwegian)              // pl (Polish)              // pt (Portuguese,              // ru (Russian)              // es (Castilian)              // sv (Swedish)              // tr (Turkish)              "detect-orientation":              true              // optional              }            

Role call

              orcImage              (              {              "Ocp-Apim-Subscription-Key":              "<your-subscription-key>"              ,              "asking-origin":"<Cull-ane-from-Supported-Regions>"              ,              "content-type":              "application/json"              ,              "url":              "image_url"              ,              "language":              "{language}"              ,              "detect-orientation":              true              }              )              .              then              (              (              issue              )              =>              {              // ORC are now in the result              }              )              .              catch              (              (              err              )              =>              {              throw              err              }              )            

Example of passing epitome by URL

              const              microsofComputerVision              =              crave              (              "microsoft-calculator-vision"              )              microsofComputerVision              .              orcImage              (              {              "Ocp-Apim-Subscription-Key":              "<your-subscription-key>"              ,              "request-origin":"<Cull-one-from-Supported-Regions>"              ,              "content-blazon":              "application/json"              ,              "url":              "http://cdn.quotesgram.com/img/81/49/660235022-Random-Funny-Quotes-.jpg"              ,              "linguistic communication":              "en"              ,              "detect-orientation":              true              }              )              .              then              (              (              result              )              =>              {              panel              .              log              (              JSON              .              stringify              (              result              )              )              // {              //     "language": "en",              //     "textAngle": 0,              //     "orientation": "Up",              //     "regions": [              //         {              //             "boundingBox": "vii,55,605,387",              //             "lines": [              //                 {              //                     "boundingBox": "7,55,603,65",              //                     "words": [              //                         {              //                             "boundingBox": "seven,59,291,61",              //                             "text": "HOME:"              //                         },              //                         {              //                             "boundingBox": "326,55,284,65",              //                             "text": "Where"              //                         }              //                     ]              //                 },              //                 ...              //             ]              //         }              //     ]              // }              }              )              .              catch              (              (              err              )              =>              {              throw              err              }              )            

Example of passing image by binary

              // Suppose yous want go ORC analysis for /tests/image/orcTest.jpg              const              microsofComputerVision              =              crave              (              "microsoft-estimator-vision"              )              fs              .              readFile              (              './tests/image/orcTest.jpg'              ,              role              (              err              ,              information              )              {              microsofComputerVision              .              orcImage              (              {              "Ocp-Apim-Subscription-Key":              "<your-subscription-key>"              ,              "asking-origin":"<Cull-i-from-Supported-Regions>"              ,              "language":              "en"              ,              "detect-orientation":              true              ,              "content-blazon":              "application/octet-stream"              ,              "body":              data              }              )              .              then              (              (              result              )              =>              {              panel              .              log              (              JSON              .              stringify              (              result              )              )              // {              //     "language": "en",              //     "textAngle": 0,              //     "orientation": "Up",              //     "regions": [              //         {              //             "boundingBox": "7,55,605,387",              //             "lines": [              //                 {              //                     "boundingBox": "seven,55,603,65",              //                     "words": [              //                         {              //                             "boundingBox": "seven,59,291,61",              //                             "text": "Dwelling:"              //                         },              //                         {              //                             "boundingBox": "326,55,284,65",              //                             "text": "Where"              //                         }              //                     ]              //                 },              //                 ...              //             ]              //         }              //     ]              // }              }              }              )              .              grab              (              (              err              )              =>              {              throw              err              }              )              }              )            

Instance of passing image by multipart/form-data

              // here use multer as multipart/course-information handler              const              microsofComputerVision              =              crave              (              "microsoft-computer-vision"              )              const              myKey              =              "xxxxxxxxx"              const              path              =              require              (              'path'              )              const              express              =              require              (              'express'              )              const              app              =              express              (              )              const              multer              =              require              (              'multer'              )              const              storage              =              multer              .              memoryStorage              (              )              const              upload              =              multer              (              {              storage:              storage              }              )              .              single              (              'paradigm'              )              app              .              mail service              (              '/upload'              ,              (              req              ,              res              ,              adjacent              )              =>              {              upload              (              req              ,              res              ,              part              (              err              )              {              if              (              err              )              {              // An error occurred when uploading              console              .              log              (              err              )              return              }              // Everything went fine              microsofComputerVision              .              orcImage              (              {              "Ocp-Apim-Subscription-Fundamental":              myKey              ,              "content-blazon":              "multipart/form-information"              ,              "language":              "en"              ,              "find-orientation":              true              ,              "body":              req              .              file              ,              "asking-origin":"westus"              }              )              .              so              (              (              result              )              =>              {              // practise stuff with result              }              )              .              catch              (              (              err              )              =>              {              throw              err              }              )              }              )              }              )            

List Domain Specific Models


Description

TThis performance returns the list of domain-specific models that are supported by the Figurer Vision API. Currently, the API only supports i domain-specific model: a celebrity recognizer.


Options

              {              "Ocp-Apim-Subscription-Key":              "A_Key"              "asking-origin":"<Cull-i-from-Supported-Regions>"              ,              // Required 1 simply              }            

Function call

              listDomainSpecificModels              (              {              "Ocp-Apim-Subscription-Key":              "<your-subscription-key>"              ,              "asking-origin":"westus"              }              )              .              then              (              (              consequence              )              =>              {              // Domain content are now in the result              }              )              .              take hold of              (              (              err              )              =>              {              throw              err              }              )            

Example of getting List Domain Specific Models

              const              microsofComputerVision              =              crave              (              "microsoft-computer-vision"              )              microsofComputerVision              .              listDomainSpecificModels              (              {              "Ocp-Apim-Subscription-Primal":              "<your-subscription-key>"              ,              "request-origin":"westus"              }              )              .              then              (              (              event              )              =>              {              console              .              log              (              JSON              .              stringify              (              outcome              )              )              // {              //   "models": [              //       {              //           "name": "celebrities",              //           "categories": [              //               "people_"              //           ]              //       }              //   ],              //   "requestId": "980399d9-c520-49b6-bf29-bbe30aae515e"              // }              }              )              .              catch              (              (              err              )              =>              {              throw              err              }              )            

Recognize Domain Specific Content


Clarification

This operation recognizes content within an image by applying a domain-specific model. The listing of domain-specific models that are supported past the Reckoner Vision API tin be retrieved using the /models Go request. Currently, the API only provides a single domain-specific model: celebrities.

Ii input methods are supported -- (one) Uploading an image binary or (2) specifying an image URL.


Options

              {              "Ocp-Apim-Subscription-Key":              "<your-subscription-cardinal>"              ,              "request-origin":"<Choose-one-from-Supported-Regions>"              ,              // Required one only              "content-blazon":              "application/json"              ,              "url":              "image_url"              ,              "model":              "{model}"              // use listDomainSpecificModels() to get current available models              }            

Role call

              recognizeDomainSpecificContent              (              {              "Ocp-Apim-Subscription-Fundamental":              "<your-subscription-key>"              ,              "request-origin":"<Cull-ane-from-Supported-Regions>"              ,              "content-type":              "application/json"              ,              "url":              "image_url"              ,              "model":              "{model}"              }              )              .              and so              (              (              result              )              =>              {              // Domain content are at present in the issue              }              )              .              grab              (              (              err              )              =>              {              throw              err              }              )            

Example of passing prototype by URL

              const              microsofComputerVision              =              require              (              "microsoft-computer-vision"              )              microsofComputerVision              .              recognizeDomainSpecificContent              (              {              "Ocp-Apim-Subscription-Key":              "<your-subscription-key>"              ,              "request-origin":"<Choose-1-from-Supported-Regions>"              ,              "content-type":              "application/json"              ,              "url":              "http://d.ibtimes.co.uk/en/full/377533/bill-gates.jpg"              ,              "model":              "celebrities"              }              )              .              so              (              (              result              )              =>              {              console              .              log              (              JSON              .              stringify              (              result              )              )              //   {              //     "requestId": "055c5645-3ec0-4dc9-9da8-98d62a28a7c2",              //     "metadata": {              //         "width": 620,              //         "height": 414,              //         "format": "Jpeg"              //     },              //     "consequence": {              //         "celebrities": [              //             {              //                 "name": "Beak Gates",              //                 "faceRectangle": {              //                     "left": 184,              //                     "pinnacle": 80,              //                     "width": 153,              //                     "height": 153              //                 },              //                 "confidence": 0.9999932              //             }              //         ]              //     }              // }              }              )              .              catch              (              (              err              )              =>              {              throw              err              }              )            

Example of passing image by binary

              // Suppose you want get model in /tests/paradigm/RDSCTest.jpg              const              microsofComputerVision              =              require              (              "microsoft-computer-vision"              )              fs              .              readFile              (              '/tests/image/RDSCTest.jpg'              ,              office              (              err              ,              data              )              {              microsofComputerVision              .              recognizeDomainSpecificContent              (              {              "Ocp-Apim-Subscription-Primal":              "<your-subscription-key>"              ,              "request-origin":"<Choose-1-from-Supported-Regions>"              ,              "model":              "celebrities"              ,              "content-type":              "awarding/octet-stream"              ,              "body":              data              }              )              .              then              (              (              result              )              =>              {              console              .              log              (              JSON              .              stringify              (              result              )              )              //   {              //     "requestId": "055c5645-3ec0-4dc9-9da8-98d62a28a7c2",              //     "metadata": {              //         "width": 620,              //         "tiptop": 414,              //         "format": "Jpeg"              //     },              //     "issue": {              //         "celebrities": [              //             {              //                 "name": "Bill Gates",              //                 "faceRectangle": {              //                     "left": 184,              //                     "top": eighty,              //                     "width": 153,              //                     "pinnacle": 153              //                 },              //                 "confidence": 0.9999932              //             }              //         ]              //     }              // }              }              }              )              .              catch              (              (              err              )              =>              {              throw              err              }              )              }              )            

Example of passing paradigm by multipart/form-data

              // here employ multer as multipart/course-data handler              const              microsofComputerVision              =              require              (              "microsoft-computer-vision"              )              const              myKey              =              "xxxxxxxxx"              const              path              =              crave              (              'path'              )              const              express              =              require              (              'express'              )              const              app              =              limited              (              )              const              multer              =              require              (              'multer'              )              const              storage              =              multer              .              memoryStorage              (              )              const              upload              =              multer              (              {              storage:              storage              }              )              .              single              (              'image'              )              app              .              post              (              '/upload'              ,              (              req              ,              res              ,              next              )              =>              {              upload              (              req              ,              res              ,              part              (              err              )              {              if              (              err              )              {              // An error occurred when uploading              panel              .              log              (              err              )              return              }              // Everything went fine              microsofComputerVision              .              recognizeDomainSpecificContent              (              {              "Ocp-Apim-Subscription-Key":              myKey              ,              "content-blazon":              "multipart/course-data"              ,              "model":              "celebrities"              ,              "body":              req              .              file              ,              "request-origin":"westus"              }              )              .              then              (              (              result              )              =>              {              // do stuff with result              }              )              .              take hold of              (              (              err              )              =>              {              throw              err              }              )              }              )              }              )            

License

This library is licensed nether MIT. Total license text is available in COPYING.

Contributing

Run into CONTRIBUTING.

jacksonemper1971.blogspot.com

Source: https://github.com/viane/microsoft-computer-vision

0 Response to "How to Upload Binary Image to Microsoft Vision Api"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel