Video detector usage


#3

i already have this class

public partial class ProcessVideo : Form, Affdex.ImageListener, Affdex.ProcessStatusListener
{

    [DllImport("winmm.dll")]
    private static extern long mciSendString(string command, StringBuilder retstring, int ReturnLength, IntPtr callBack);
    private FilterInfoCollection videoDevices;
    private VideoCaptureDevice videoSource = null;
   
    private string path;

    public ProcessVideo(Affdex.Detector detector)
    {
        
        //Thread camThread = new  Thread(camStart);
        //camThread.Start();
        detector.setImageListener(this);
        detector.setProcessStatusListener(this);
        InitializeComponent();
        label2.Text = generateSentence();
        mciSendString("open new Type waveaudio alias recsound", null, 0, IntPtr.Zero);
        button1.Click += new EventHandler(this.button1_Click);
       
    }

and i initialized a variable “feed” from this class that implements image listener and processStatusListener
although detector.process() shows an error that it doesnt have a definition for process.


#4

oh, that’s because you declared detector as an Affdex.Detector rather than an Affdex.VideoDetector. The base class does not have the process method.


#5

yes okay i will try this.thanks


#6

i faced this exception any ideas how to solve it ??


#7

Yes, make sure you have the opencv_ffmpeg248_64.dll (located in C:\Program Files\Affectiva\AffdexSDK\bin, or wherever you installed the SDK) on your path.

Sorry, I think the documentation is not clear about that; I’ll make a note to fix it.


#8

it is already in it, i tried opening an AVI file instead of MP4 but same error


#9

Hi, can you show your PATH?


#10

the path of the SDK ??


#11

Sorry, no, your PATH environment variable.


#12

image

this is the path of the enviroment variable


#13

Hi, OK, from a command window, please do the following and copy/paste the output:

  1. echo %PATH%

  2. cd to the folder where your application’s .EXE file lives and run it (which should produce the error you showed above – “Error opening video file”).

Thanks.


#14

i dont get which path should i include in echo ??
then i should cd to which exe file the project ?


#15
Microsoft Windows [Version 10.0.17134.48]
(c) 2018 Microsoft Corporation. All rights reserved.

C:\Users\Rana> echo C:\Program Files\Affectiva\AffdexSDK\bin\release
C:\Program Files\Affectiva\AffdexSDK\bin\release

C:\Users\Rana>cd C:\Users\Rana\Documents\Visual Studio 2015\Projects\new vid\proj2\bin\x64\Release

C:\Users\Rana\Documents\Visual Studio 2015\Projects\new vid\proj2\bin\x64\Release>proj2.exe
ranunaaa
all functions on
2018-06-01 14:55:19.235993: W c:\jenkins\workspace\tensorflow-win64- 
release\src\tensorflow\core\platform\cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to 
use SSE instructions, but these are available on your machine and could speed up CPU computations.
2018-06-01 14:55:19.240989: W c:\jenkins\workspace\tensorflow-win64- 
release\src\tensorflow\core\platform\cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to 
use SSE2 instructions, but these are available on your machine and could speed up CPU computations.
2018-06-01 14:55:19.244502: W c:\jenkins\workspace\tensorflow-win64- 
release\src\tensorflow\core\platform\cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to 
use SSE3 instructions, but these are available on your machine and could speed up CPU computations.
2018-06-01 14:55:19.248619: W c:\jenkins\workspace\tensorflow-win64- 
release\src\tensorflow\core\platform\cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to 
use SSE4.1 instructions, but these are available on your machine and could speed up CPU computations.
2018-06-01 14:55:19.252210: W c:\jenkins\workspace\tensorflow-win64- 
release\src\tensorflow\core\platform\cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to 
use SSE4.2 instructions, but these are available on your machine and could speed up CPU computations.
2018-06-01 14:55:19.257157: W c:\jenkins\workspace\tensorflow-win64- 
release\src\tensorflow\core\platform\cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to 
 use AVX instructions, but these are available on your machine and could speed up CPU computations.
 2018-06-01 14:55:19.261606: W c:\jenkins\workspace\tensorflow-win64- 
release\src\tensorflow\core\platform\cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to 
 use AVX2 instructions, but these are available on your machine and could speed up CPU computations.
2018-06-01 14:55:19.268125: W c:\jenkins\workspace\tensorflow-win64- 
release\src\tensorflow\core\platform\cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to 
use 
FMA instructions, but these are available on your machine and could speed up CPU computations.
 detector started
 detector stopped
faces count
1
Engagement:56.91
Valence:75.99
Contempt:0.00
Surprise:0.25
Anger:0.00
Sadness:0.00
Disgust:0.02
Fear:0.00
Joy:9.55
done

Unhandled Exception: Affdex.AffdexException: Detector is not initialized, must call start() before reset()
 at Affdex.Detector.reset()
 at proj2.Program.Main(String[] args) in C:\Users\Rana\Documents\Visual Studio 2015\Projects\new 
 vid\proj2\Program.cs:line 42

#16

Hi, I want to see the value of your PATH environment variable, prior to executing your program. You can do this using the command echo %PATH% from the command prompt.

However, it looks like you are not getting that error any more, so maybe you solved it?


#17


#18

It looks like you are not executing the command echo %PATH%, but rather echo C:\Program Files\Affectiva\AffdexSDK\bin\release.

An equivalent way to show the value of your PATH environment variable would be to just execute the command path, if that would be easier.


#19


#20

OK, thanks, so that looks good, and explains why you’re not getting the earlier error anymore. You’ve probably already figured out from the other error (“Detector is not initialized, must call start() before reset()”) that you do not need to call reset() at the end.


#22

but in the walkthrough it was said that i should call reset(), and the error is still the same whenever i debug from visual studio .


#23

You do not need to call reset after stop. If you want to reset the face IDs, timestamps, and the processing state while the detector is running, you can call reset to do that (between calls to start and stop).

If you are getting the earlier error about being unable to read the video in Visual Studio, it is because the PATH environment variable in the Visual Studio process does not include the Affectiva\AffdexSDK\bin directory. If you have set the PATH environment variable in the command window only; then it is only set in the context of that command window. If you set it via Control Panel, then it is only inherited by processes created after doing that. So probably you need to restart your Visual Studio in order for it to pick up the new PATH.