Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Cognitive Services の新しい UWP サンプルアプリ “Intelligent Kiosk” – Face API & Emotion API による顔認識ダッシュボード

Cognitive Services SDK & Samples

Microsoft Cognitive Services > SDK & Samples

この中に表示されているサンプルに、 UWP版のVision系(Computer Vision, Face, Emotion) API を使った “Intelligent Kiosk” が追加されました。

GitHub > Microsoft Cognitive Services Intelligent Kiosk Sample

“Intelligent Kiosk” UWP サンプルアプリ

内容は、Face API と Emotion Api による写真 or デバイスで撮影した画像の解析になっています。

  1. Face API Playground: 写真 or デバイスで撮影した画像の解析 (年齢識別)
  2. Emotion API Playground: 写真 or デバイスで撮影した画像の解析(感情識別)
  3. Automatic Photo Capture: デバイスのカメラで撮影中の動画から顔を認識して年齢識別
  4. Realtime Crowd Insights: デバイスのカメラで撮影中の動画から顔を認識して年齢、感情識別

顔の登録もできるので、1で画像解析するときに年齢と同時に顔識別を行うこともできます。

また、 4はカメラで撮影中の動画に現れる顔の認知 (男女、年齢層、総人数 および ユニークな人数をカウント) や表情のチェック (累積数をカウント) を行い、一日のデータ履歴も合わせて表示します。そのため、例えば店舗に設置して来場者の表情から満足度を量るダッシュボードのような利用シナリオにそのまま活用できる内容になっています。(※下記はイメージです)

サンプルコードを一部解説

GitHub から一式ダウンロードすると、Cognitive-Samples-IntelligentKiosk-masterKiosk に Visual Studio ソリューション一式が入っています。中身は “IntelligentKioskSample” という UWP(Universal Windows Platform) 本体と、Cognitive Serivices とのやり取りを行う “Service Helpers” に分かれています。

Face API の呼び出し例

FaceServiceClient を作成し、API Key をセット

FaceServiceHelper.cs
private static FaceServiceClient faceClient { get; set; }

private static void InitializeFaceServiceClient()
   {
     faceClient = new FaceServiceClient(apiKey);
   }

DetectFacesAsync から FaceServiceClient.DetectAsync を呼び出すフローになっています。

ServiceHelpers.ImageAnalyzer.cs
public async Task DetectFacesAsync(bool detectFaceAttributes = false)
:
   if (this.ImageUrl != null)
   {
      this.DetectedFaces = await FaceServiceHelper.DetectAsync(
      this.ImageUrl,
      returnFaceId: true,
      returnFaceLandmarks: false,
      returnFaceAttributes: detectFaceAttributes ? DefaultFaceAttributeTypes : null);
   }
FaceServiceHelper.cs
public static async Task DetectAsync(string url, bool returnFaceId = true,
      bool returnFaceLandmarks = false,
      IEnumerable returnFaceAttributes = null)
   {
      return await RunTaskWithAutoRetryOnQuotaLimitExceededError(()
       => faceClient.DetectAsync(url, returnFaceId, returnFaceLandmarks, returnFaceAttributes));
   }  
        

Share the post

Cognitive Services の新しい UWP サンプルアプリ “Intelligent Kiosk” – Face API & Emotion API による顔認識ダッシュボード

×

Subscribe to Msdn Blogs | Get The Latest Information, Insights, Announcements, And News From Microsoft Experts And Developers In The Msdn Blogs.

Get updates delivered right to your inbox!

Thank you for your subscription

×