Search code examples
c#interfaceaffdex-sdk

Affdex videodetector


I'm currently doing a project where I have to use the Affectiva SDK to analyse some videos that I have recorded. I have downloaded the files, which they have given me and started writing the code for the SDK to work, however when calling the callback functions in my code, Visual Studio doesn't seem to accept the arguments that are put in. So I figured that the interfaces for the callback functions must be done. I'm not really clear on how to this though, since I thought this was all done in their assembly code. My code so far looks like this:

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();
    }
}

}

As far as I know, I have to write code for the interfaces if I'm not mistaken... Or do I? Please help.


Solution

  • Here is a tutorial on getting started to analyze the video files.

    As far as I know, I have to write code for the interfaces if I'm not mistaken... Or do I?

    No you don't. You just have to implement the methods in the interfaces if you were to use them.

    Here is the link to the sample app that uses Camera Detector which you can relate to since both the Camera Detector and the Video Detector implement the FaceListener, ProcessListener and ImageListener Interfaces.

    EDIT: You have to implement the Listeners. For example in the code sample you are using the FaceListener so you need to write the implementation for the callbacks viz onFaceFound() and onFaceLost().

    You may also want to create an object of processStatusListener and wait for the process to end for a video file something like this:

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

    Here is a link to our C# app AffdexMe which uses CameraDetector. You may find examples of CameraDetector, PhotoDetector, VideoDetector and FrameDetector in our getting started guide.