際際滷

際際滷Share a Scribd company logo
Xamarin で Cognitive Services を聞ってみよう
Xamarin で Cognitive Services を聞ってみよう
Xamarin で Cognitive Services を聞ってみよう
Xamarin で Cognitive Services を聞ってみよう
Xamarin で Cognitive Services を聞ってみよう
Xamarin で Cognitive Services を聞ってみよう
// FaceClient
FaceClient faceClient = new FaceClient(new ApiKeyServiceClientCredentials("<Face API Key>"),
new System.Net.Http.DelegatingHandler[] { });
faceClient.Endpoint = "<Face API Endpoint>";
//
FaceAttributeType[] faceAttributes = { FaceAttributeType.Age, FaceAttributeType.Gender, FaceAttributeType.Emotion };
// API ,
IList<DetectedFace> faceList = await faceClient.Face.DetectWithUrlAsync("<Image URL>", true, false, faceAttributes);
//
List<FaceEmotion> emotions = new List<FaceEmotion>();
foreach (var face in faceList)
{
emotions.Add(new FaceEmotion
{
Age = face.FaceAttributes.Age,
Gender = ((Gender)face.FaceAttributes.Gender).ToString(),
Happiness = face.FaceAttributes.Emotion.Happiness * 100d
});
}
// ComputerVisionClient
var cvClient = new ComputerVisionClient(new ApiKeyServiceClientCredentials("<Face API Key>"),
new System.Net.Http.DelegatingHandler[] { });
cvClient.Endpoint = "<Face API Endpoint>";
// API
var textHeaders = await cvClient.RecognizeTextAsync("<Image URL>", TextRecognitionMode.Handwritten);
var operationLocation = textHeaders.OperationLocation;
var operationId = textHeaders.OperationLocation.Substring(operationLocation.Length - numberOfCharsInOperationId);
// API
var result = await cvClient.GetTextOperationResultAsync(operationId);
var lines = result.RecognitionResult.Lines;
//
var sb = new StringBuilder();
foreach (var line in lines)
{
sb.Append(line.Text);
}
Xamarin で Cognitive Services を聞ってみよう
Xamarin で Cognitive Services を聞ってみよう
Xamarin で Cognitive Services を聞ってみよう
Xamarin で Cognitive Services を聞ってみよう
Xamarin で Cognitive Services を聞ってみよう
Xamarin で Cognitive Services を聞ってみよう
Xamarin で Cognitive Services を聞ってみよう

More Related Content

Xamarin で Cognitive Services を聞ってみよう

  • 7. // FaceClient FaceClient faceClient = new FaceClient(new ApiKeyServiceClientCredentials("<Face API Key>"), new System.Net.Http.DelegatingHandler[] { }); faceClient.Endpoint = "<Face API Endpoint>"; // FaceAttributeType[] faceAttributes = { FaceAttributeType.Age, FaceAttributeType.Gender, FaceAttributeType.Emotion }; // API , IList<DetectedFace> faceList = await faceClient.Face.DetectWithUrlAsync("<Image URL>", true, false, faceAttributes); // List<FaceEmotion> emotions = new List<FaceEmotion>(); foreach (var face in faceList) { emotions.Add(new FaceEmotion { Age = face.FaceAttributes.Age, Gender = ((Gender)face.FaceAttributes.Gender).ToString(), Happiness = face.FaceAttributes.Emotion.Happiness * 100d }); }
  • 8. // ComputerVisionClient var cvClient = new ComputerVisionClient(new ApiKeyServiceClientCredentials("<Face API Key>"), new System.Net.Http.DelegatingHandler[] { }); cvClient.Endpoint = "<Face API Endpoint>"; // API var textHeaders = await cvClient.RecognizeTextAsync("<Image URL>", TextRecognitionMode.Handwritten); var operationLocation = textHeaders.OperationLocation; var operationId = textHeaders.OperationLocation.Substring(operationLocation.Length - numberOfCharsInOperationId); // API var result = await cvClient.GetTextOperationResultAsync(operationId); var lines = result.RecognitionResult.Lines; // var sb = new StringBuilder(); foreach (var line in lines) { sb.Append(line.Text); }