Skip to main content

Request

Namespace: Wisej.Ext.CognitiveServices

Assembly: Wisej.Ext.CognitiveServices (4.1.0.0)

Represents the result of an image analysis request processed by the CognitiveServices component.

public class Request

Instances of this class are created by the CognitiveServices component and are available through LastRequest after StartAnalysisRequest completes.

Example:

this.cognitiveServices1.StartAnalysisRequest(File.ReadAllBytes(Application.MapPath("Images/photo.jpg")));

// later, once the analysis has completed:
Request request = this.cognitiveServices1.LastRequest;
if (request != null)
this.labelDescription.Text = request.Description;

Properties​

Instance member Adult​

AdultInfo: Returns the adult and racy content information detected in the image.

Example:

Request request = this.cognitiveServices1.LastRequest;
if (request.Adult.isAdultContent || request.Adult.isRacyContent)
this.pictureBox1.Visible = false;

Instance member Captions​

String[]: Returns the captions describing the image in complete sentences, or null if none were returned.

Example:

Request request = this.cognitiveServices1.LastRequest;
if (request.Captions != null)
this.label1.Text = String.Join(Environment.NewLine, request.Captions);

Instance member Categories​

Category[]: Returns the categories that classify the image content, or null if none were returned.

Example:

Request request = this.cognitiveServices1.LastRequest;
foreach (var category in request.Categories)
this.listBox1.Items.Add($"{category.name} ({category.score:P0})");

Instance member Celebrities​

Celebrity[]: Returns the celebrities identified in the image, or null if none were returned.

Example:

Request request = this.cognitiveServices1.LastRequest;
foreach (var celebrity in request.Celebrities)
this.listBox1.Items.Add($"{celebrity.name} ({celebrity.confidence:P0})");

Instance member Description​

String: Returns the description of the image content.

Example:

Request request = this.cognitiveServices1.LastRequest;
this.label1.Text = request.Description;

Instance member Faces​

Face[]: Returns the faces detected in the image, or null if none were returned.

Example:

Request request = this.cognitiveServices1.LastRequest;
foreach (var face in request.Faces)
this.listBox1.Items.Add($"{face.gender}, {face.age} at {face.faceRectangle.left},{face.faceRectangle.top}");

Instance member Landmarks​

Landmark[]: Returns the landmarks identified in the image, or null if none were returned.

Example:

Request request = this.cognitiveServices1.LastRequest;
foreach (var landmark in request.Landmarks)
this.listBox1.Items.Add($"{landmark.name} ({landmark.confidence:P0})");

Instance member MetaData​

MetaDataInfo: Returns the metadata of the analyzed image (format and size).

Example:

Request request = this.cognitiveServices1.LastRequest;
this.label1.Text = $"{request.MetaData.imageType}: {request.MetaData.imageWidth} x {request.MetaData.imageHeight}";

Instance member Result​

String: Returns the raw JSON string returned by the Cognitive Services API.

Example:

Request request = this.cognitiveServices1.LastRequest;
AlertBox.Show(request.Result);

Instance member Tags​

Tag[]: Returns the tags related to the image content, or null if none were returned.

Example:

Request request = this.cognitiveServices1.LastRequest;
foreach (var tag in request.Tags)
this.listBox1.Items.Add($"{tag.name} ({tag.confidence:P0})");