我刚开始使用 Affectiva SDK for C#,经过几次运行,我偶然发现了一个持续崩溃的问题。我在 x86 架构和 .Net 4.5.1 上使用相机处理。我安装了 VS 2013。我的操作系统是 Windows 10。我在输出中添加了“opencv_ffmpeg248”和“affdex-native”。代码构建并运行正常,但在运行时,它有时会抛出此错误并关闭应用程序。
这是我正在使用的代码:
public class Class1 : Affdex.ImageListener
{
private Affdex.CameraDetector _detector;
public event EventHandler<string[]> AllValuesEvent;
public Class1()
{
_detector = new Affdex.CameraDetector();
_detector.setDetectAllEmotions(true);
_detector.setDetectAllAppearances(true);
String classifierPath = @"C:\Program Files (x86)\Affectiva\Affdex SDK\data";
_detector.setClassifierPath(classifierPath);
_detector.setImageListener(this);
_detector.start();
}
public void StopCamera()
{
_detector.stop();
}
public void onImageCapture(Frame frame)
{
}
public void onImageResults(Dictionary<int, Face> faces, Frame frame)
{
if (faces.Count > 0)
{
Face face = faces.First().Value;
Console.WriteLine("Age: {0} Gender: {1} Glasses: {2}",
face.Appearance.Age,
face.Appearance.Gender,
face.Appearance.Glasses);
string[] names = new string[8];
string[] values = new string[8];
names[0] = "Anger";
names[1] = "Contempt";
names[2] = "Disgust";
names[3] = "Engagement";
names[4] = "Fear";
names[5] = "Joy";
names[6] = "Sadness";
names[7] = "Surprise";
values[0] = face.Emotions.Anger.ToString("F2");
values[1] = face.Emotions.Contempt.ToString("F2");
values[2] = face.Emotions.Disgust.ToString("F2");
values[3] = face.Emotions.Engagement.ToString("F2");
values[4] = face.Emotions.Fear.ToString("F2");
values[5] = face.Emotions.Joy.ToString("F2");
values[6] = face.Emotions.Sadness.ToString("F2");
values[7] = face.Emotions.Surprise.ToString("F2");
RaiseAllValuesEvent(names, values);
}
}
private void RaiseAllValuesEvent(string[] names, string[] values)
{
if (AllValuesEvent != null)
{
AllValuesEvent(names, values);
}
}
}
有人有什么建议吗?
非常感谢。