CognitiveServices
The CognitiveServices component is meant to analyze images with Microsoft's Azure AI Vision service, formerly Cognitive Services Computer Vision. It sends an image to the service's REST analyze endpoint and requests visual features such as a description, tags, categories, faces, landmarks, celebrities or adult-content scores.
This extension is marked work in progress in its source repository, and it isn't published on NuGet. In the 4.1 source, StartAnalysisRequest posts the image to the service but discards the response. No event is raised, and LastRequest is never filled in. The component can't be used as is in an application.
To analyze images today, call Azure AI Vision directly from your server code with Microsoft's Azure AI Vision SDK or its REST API. Or treat this project as a starting point and finish it in your own copy of the source.
What the component contains
| Member | What it is |
|---|---|
SubscriptionKey | The resource key, sent in the Ocp-Apim-Subscription-Key header. |
UriBase | The regional analyze endpoint of your resource. The region must match the key. |
RequestParameters | The query string appended to UriBase, for example visualFeatures=Categories,Description,Color&language=en. |
StartAnalysisRequest(imageData) | Posts the image bytes (JPEG, PNG, GIF or BMP) as application/octet-stream. It returns immediately. |
Request | A model of the analysis result: Description, Captions, Tags, Categories, Faces, Celebrities, Landmarks, Adult and MetaData. |
VisualFeatures / Details | The feature names you can list in visualFeatures and details. |
The examples in the source use the vision/v1.0/analyze endpoint. Microsoft has since retired Computer Vision v1.0, and current resources expose the Image Analysis 3.2 and 4.0 APIs, whose URLs and response formats differ. Check the endpoint against your Azure resource.
The key grants access to your paid Azure resource. The component makes its requests from the server, so the key never has to reach the browser. Don't hard-code it: read it from configuration, environment variables or Azure Key Vault.
API reference
CognitiveServicesRequest,VisualFeaturesandDetails- The whole
Wisej.Ext.CognitiveServicesnamespace