Advertisement
Guest User

Untitled

a guest
Jun 29th, 2016
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. using System;
  2. using System.Diagnostics;
  3. using System.IO;
  4. using System.Windows;
  5. using Microsoft.ProjectOxford.Face;
  6.  
  7. namespace FaceWpf
  8. {
  9. public partial class MainWindow : Window
  10. {
  11. public MainWindow()
  12. {
  13. InitializeComponent();
  14. }
  15.  
  16. const string SubscriptionKey = "0123456789abcdef0123456789abcdef";
  17. const string ImagePath = @"Images\temp.jpg";
  18.  
  19. FaceServiceClient client = new FaceServiceClient(SubscriptionKey);
  20.  
  21. async void DetectAsync()
  22. {
  23. try
  24. {
  25. using (var stream = File.OpenRead(ImagePath))
  26. {
  27. var result = await client.DetectAsync(stream, returnFaceAttributes: (FaceAttributeType[])Enum.GetValues(typeof(FaceAttributeType)));
  28.  
  29. // 各情報を取り出します。
  30. var age = result[0].FaceAttributes.Age;
  31. var rectangle = result[0].FaceRectangle;
  32. }
  33. }
  34. catch (Exception ex)
  35. {
  36. Debug.WriteLine(ex);
  37. }
  38. }
  39. }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement