2016-10-05 9 views
0

私は最近、Affectiva SDK(http://www.affectiva.com/)をインストールし、カメラからの入力を分析するチュートリアル(http://developer.affectiva.com/v3/android/analyze-camera/)に従った。残念ながら、このプロジェクトは機能していないようです。顔が検出されたときなどは、FaceListener, ImageListener, ProcessStatusListenerのインタフェース/コールバック関数を呼び出す必要があります(これは正しい)と私は理解しています。Affectivaがコールバック関数を呼び出す方法を教えてください。

エラーは発生しませんが、これらの関数は決して呼び出されません(Visual StudioではConsole.WriteLineステートメントと配置されたブレークポイントが置かれています)。時々、一連の「イメージキャプチャ」ステートメントがコンソールに表示されますが、その発生の仕方や理由をまだ再現できません。誰かが私が間違ったことを知っていますか?助けをありがとうございました。以下は


これまでの私のコードです:

App.xaml.cs

using Affdex; 
using System; 
using System.Collections.Generic; 
using System.Configuration; 
using System.Data; 
using System.Linq; 
using System.Threading.Tasks; 
using System.Windows; 

namespace Affectiva 
{ 

    /// <summary> 
    /// Interaction logic for App.xaml 
    /// </summary> 
    public partial class App : Application, FaceListener, ImageListener, ProcessStatusListener 
    { 
     public static CameraDetector detector; 
     int camId = 10; 
     int camFPS = 60; 

     public App(){ 
      detector = new CameraDetector(); 
      String classifierPath = "C:\\Program Files (x86)\\Affectiva\\Affdex SDK\\data"; 
      detector.setClassifierPath(classifierPath); 

      detector.setCameraId(camId); 
      detector.setCameraFPS(camFPS); 

      detector.setFaceListener(this); 
      detector.setImageListener(this); 
      detector.setProcessStatusListener(this); 

      detector.setDetectSmile(true); 
      detector.setDetectJoy(true); 

      detector.setDetectAllExpressions(true); 
      detector.setDetectAllEmotions(true); 
      detector.setDetectAllEmojis(true); 
      detector.setDetectAllAppearances(true); 
     } 

     public void onFaceFound(float f, int i) 
     { 
      Console.WriteLine("Face Found!"); 
     } 

     public void onFaceLost(float f, int i) 
     { 
      Console.WriteLine("Face Lost!"); 
     } 

     public void onImageResults(Dictionary<int, Face> faces, Frame f){ 
      Console.WriteLine("OnImageResults - " + faces.Count); 
      if(faces.Count > 0) 
       Console.WriteLine(faces.First().Value.Appearance.Age); 
     } 

     public void onImageCapture(Frame f){ 
      Console.WriteLine("Image Captured " + f.getHeight()); 
     } 

     public void onProcessingFinished() 
     { 
      Console.WriteLine("Processing Finished"); 
     } 

     public void onProcessingException(AffdexException e) 
     { 
      Console.WriteLine(e.Message); 
     } 
    } 
} 

MainWindow.xaml.cs

using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Text; 
using System.Threading; 
using System.Threading.Tasks; 
using System.Windows; 
using System.Windows.Controls; 
using System.Windows.Data; 
using System.Windows.Documents; 
using System.Windows.Input; 
using System.Windows.Media; 
using System.Windows.Media.Imaging; 
using System.Windows.Navigation; 
using System.Windows.Shapes; 
using System.Windows.Threading; 
using WebEye.Controls.Wpf; 

namespace Affectiva 
{ 
    /// <summary> 
    /// Interaction logic for MainWindow.xaml 
    /// </summary> 
    public partial class MainWindow : Window 
    { 
     public MainWindow() 
     { 
      InitializeComponent(); 
     } 

     private void OnStartButtonClick(object sender, RoutedEventArgs e) 
     { 
      var cameraId = webCameraControl.GetVideoCaptureDevices().First(); 
      webCameraControl.StartCapture(cameraId); 
      App.detector.start(); 
     } 
    } 
} 

答えて

0

あなたは間違ったドキュメントを見ていると思います。Windows SDK hereの正しいドキュメントを見つけることができます。コードスニペットを簡単に見て、int camId = 10;を設定しています。これは、検出器がシステム上でIDが10のカメラを探していることを意味します。デフォルトでは、組み込みカメラにはid = 0があります。デフォルトのCameraIdを0に設定し、フレームを処理するレートを30.HereはCameraDetectorのデフォルトのコンストラクタ定義です。

このexampleを使用してカメラのフィードを分析することができます。主にAffdex-Mecsharp-sample-appsのgithubで利用できるアプリケーションも用意されています。

+0

おっと、間違ったドキュメントをリンクしました。私は実際に[this](http://developer.affectiva.com/v3_1_1/windows/analyze-camera/)のドキュメントを使用しました。 idのことはとてもばかげたミスのように思えますが、今は0に変更しましたが、残念ながらまだ動作しません。 私はあなたのギターの例を見て、私がそれらから学ぶことができるかどうかを見ていきます。あなたのお返事ありがとうございます! – Wouter

関連する問題