1

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

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/sdk_ahmedmudi1992@gmail.com.license";
        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();
    }
}

}

据我所知,如果我没记错的话,我必须为接口编写代码......或者我是吗?请帮忙。

4

1 回答 1

0

这是开始分析视频文件的教程。

据我所知,如果我没记错的话,我必须为接口编写代码......或者我是吗?

不,你没有。如果你要使用它们,你只需要实现接口中的方法。

这是使用相机检测器的示例应用程序的链接,您可以将其关联起来,因为相机检测器和视频检测器都实现了FaceListenerProcessListenerImageListener接口。

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

您可能还想创建一个 processStatusListener 对象并等待进程结束以获取类似这样的视频文件:

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

这是使用 CameraDetector的C# 应用程序 AffdexMe的链接。您可以在我们的入门指南中找到 CameraDetector、PhotoDetector、VideoDetector 和 FrameDetector 的示例。

于 2016-04-25T15:12:02.437 回答