2016-04-24 222 views
1

我目前正在做一个项目,我必须使用Affectiva SDK来分析我录制的一些视频。我已经下载了他们给我的文件,并开始编写SDK的代码来工作,但是当我在代码中调用回调函数时,Visual Studio似乎不接受放入的参数。所以我想回调函数的接口必须完成。我不清楚如何做到这一点,因为我认为这些都是在汇编代码中完成的。到目前为止我的代码看起来是这样的:Affdex视频检测器

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


namespace ConsoleApplication2 
{ 
class Program 
{ 
    public interface FaceListener { } 
    public interface ImageListener { } 
    public interface ProcessStatusListener { } 

    static void Main(string[] args) 
    { 
     VideoDetector detector = new VideoDetector(15); 

     String licensePath = "C:/Users/hamud/Desktop/[email protected]"; 
     detector.setLicensePath(licensePath); 

     String classifierPath = "C:/Programmer/Affectiva/Affdex SDK/data"; 
     detector.setClassifierPath(classifierPath); 

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

     detector.setDetectSmile(true); 
     detector.setDetectSurprise(false); 
     detector.setDetectBrowRaise(false); 
     detector.setDetectAnger(false); 
     detector.setDetectDisgust(false); 
     detector.setDetectAllExpressions(false); 

     detector.start(); 

     detector.stop(); 
    } 
} 

}

据我知道,我必须编写代码的接口,如果我没有记错......还是我?请帮忙。

回答

0

以下是关于开始分析视频文件的tutorial

据我所知,如果我没有弄错,我必须为接口编写代码......或者我呢?

不,你不知道。如果你要使用它们,你只需要在接口中实现这些方法。

这里是链接到示例应用程序使用摄像机探测器,它可以涉及到,因为在相机检测和视频检测器实现FaceListenerProcessListenerImageListener接口。

编辑:你必须实现听众。例如,在代码示例中,您正在使用FaceListener,因此您需要编写回调的实现,即onFaceFound()onFaceLost()

您也可能希望创建processStatusListener的对象,并等待进程结束的视频文件是这样的:

AffdexProcessStatusListener processStatusListener = new AffdexProcessStatusListener(); 
processStatusListener.wait(); 

这里是我们的C# app AffdexMe一个链接,使用CameraDetector。您可以在我们的getting started guide中找到CameraDetector,PhotoDetector,VideoDetector和FrameDetector的例子。

+0

我已经试过了这个教程,但是我似乎无法得到它的工作。顺便说一句,你指的是相机探测器的链接? –

+0

@MartinMansour:我已经编辑了上面的回复请看看。 –

+0

@MartinMansour是否解决了您的问题? –