Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Diagnostics;
- using System.IO;
- using System.Windows;
- using Microsoft.ProjectOxford.Face;
- namespace FaceWpf
- {
- public partial class MainWindow : Window
- {
- public MainWindow()
- {
- InitializeComponent();
- }
- const string SubscriptionKey = "0123456789abcdef0123456789abcdef";
- const string ImagePath = @"Images\temp.jpg";
- FaceServiceClient client = new FaceServiceClient(SubscriptionKey);
- async void DetectAsync()
- {
- try
- {
- using (var stream = File.OpenRead(ImagePath))
- {
- var result = await client.DetectAsync(stream, returnFaceAttributes: (FaceAttributeType[])Enum.GetValues(typeof(FaceAttributeType)));
- // 各情報を取り出します。
- var age = result[0].FaceAttributes.Age;
- var rectangle = result[0].FaceRectangle;
- }
- }
- catch (Exception ex)
- {
- Debug.WriteLine(ex);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement