No output after runing the code


#1

after looking into it,i figured out that it doesnt reach the 1st foreach loop in onImageResult() function,because faces.count=o,

i dont know where the problem is ??

here is the code:

namespace proj2
{
    class Program
    {
        static void Main(string[] args)
        {
            Affdex.Detector detector = new Affdex.CameraDetector(0,1,1);
            ProcessVideo feed = new ProcessVideo(detector);
            System.Console.WriteLine("ranunaaa");
            detector.setClassifierPath("C:\\Program Files\\Affectiva\\AffdexSDK\\data");
            detector.setDetectAllEmotions(true);
            detector.setDetectAllEmojis(true);
            detector.setDetectAllExpressions(true);
            detector.setDetectAge(true);
            detector.setDetectGender(true);
            detector.setDetectGlasses(true);
            System.Console.WriteLine("ranunaaa11");
            detector.start();
            System.Console.WriteLine("ranunaaa22");
             feed.ShowDialog();
             System.Console.WriteLine("ranunaaa33");
             detector.stop();
        }
    }
}

the second part

namespace proj2
{
public partial class ProcessVideo : Form, Affdex.ImageListener
{
    public ProcessVideo(Affdex.Detector detector)
    {
        detector.setImageListener(this);
        InitializeComponent();
    }

    public void onImageCapture(Affdex.Frame frame)
    {

        frame.Dispose();
    }
    public void onImageResults(Dictionary<int, Affdex.Face> faces, Affdex.Frame frame)
    {
        System.Console.WriteLine("ranunaaa44");
        foreach (KeyValuePair<int, Affdex.Face> pair in faces)
        {
            Affdex.Face face = pair.Value;
            if (faces != null)
            {
                foreach (PropertyInfo prop in typeof(Affdex.Emotions).GetProperties())
                {
                    float value = (float)prop.GetValue(face.Emotions, null);
                    string output = string.Format("{0}:{1:N2}", prop.Name, value);
                    System.Console.WriteLine(output);
                }
            }
        }
        frame.Dispose();
    }
}

}


#2

Is onImageResults being called once per second? If so, try writing the frames out to image files to make sure they contain faces.

It may also be useful to try https://github.com/Affectiva/affdexme-win, just to make sure the CameraDetector is able to integrate successfully with your camera.


#3

how can i write the frames out to images ??
i already did run affdexme-win and it is working fine.


#4

Sorry, I’m afraid don’t have any code handy to give you for writing the frames out. I imagine you could create a Bitmap from the Frame’s raw data (by calling getBGRByteArray()), then write that to a file.


#5

i guess the images are corrupted this is the image :Capture


#6

Just to verify your image writing code, can you add it to AffdexMe and make sure the images are good in that context?


#7

thanks the issue is resolved


#8