luca-m / emotime

Recognizing emotional states in faces
139 stars 65 forks source link

OpenCV Error: Bad argument (The SVM should be trained first) #48

Closed crankdaworld closed 9 years ago

crankdaworld commented 9 years ago

Hi, Can you help me with this error?

./emotimegui_cli ../resources/haarcascade_frontalface_cbcl1.xml none 48 48 3 5 4 svm ../dataset_svm_354_cbcl1_1vsallext/classifiers/svm/* OpenCV Error: Bad argument (The SVM should be trained first) in CvSVM::predict, file /opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_tarballs_ports_graphics_opencv/opencv/work/opencv-2.4.11/modules/ml/src/svm.cpp, line 2131 libc++abi.dylib: terminating with uncaught exception of type cv::Exception: /opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_tarballs_ports_graphics_opencv/opencv/work/opencv-2.4.11/modules/ml/src/svm.cpp:2131: error: (-5) The SVM should be trained first in function CvSVM::predict

Abort trap: 6

Thanks

crankdaworld commented 9 years ago

Has this been tested on mac os x 10.9? or only windows and linux?

luca-m commented 9 years ago

I suppose you are the first official osx tester :) are you sure you are using the right parameters for the trained xml model you have specified? or also try to expand "*" manually.. Are you using v1.2 ?

crankdaworld commented 9 years ago

Hi Luca, Yes, for 1.2 i am able to run it on mac.
./emotimegui_cli ../resources/haarcascade_frontalface_cbcl1.xml ../resources/haarcascade_eye.xml 52 52 1 5 8 svm ../svm_1vsallext/classifiers/svm/* . Issue was that, the model folder was inside assets folder. I moved it and its working now. Its very slow.!

Next step. I downloaded the master from git and trying to get this running. Getting issues.... python gui.py --cfg ../svm_1vsallext/dataset.cfg --mode svm --eye-correction ../dsFolder Launching emotime gui! Smile :) OpenCV Error: Sizes of input arguments do not match (The sample size is different from what has been used for training) Couple of things

  1. Can i use the model downloaded for 1.2 into existing master?
  2. Should i train the model - CK?

Thanks

luca-m commented 9 years ago

Hi,

Just another little question: Have you downloaded the source code and the model from release 1.2 page and then compiled it? Performance issue were solved in 1.2, if you use 1.1 binaries this could happen (and models are not compatible)

Also in 1.2 release page there are command examples. However these models should also run with master.

If you'd like to train it your self you can quite easily, just ask for a copy of the CK and in a few\ minutes you can train models.

crankdaworld commented 9 years ago

I have downloaded master code and used models from 1.2 . I will test it using 1.2 for both source and model .

crankdaworld commented 9 years ago

Observations

  1. rel 1.2 . Used source code and built them. Used Trained models provided.
  2. This command executes ./emotimegui_cli ../resources/haarcascade_frontalface_cbcl1.xml ../resources/haarcascade_eye.xml 52 52 1 5 8 svm ../svm_1vsallext_1_5_8_95c2eb0b58/*
  3. When i try to execute this command python gui.py --cfg ../dsFolder/dataset.cfg --mode svm --eye-correction ../dsFolder/ it fails Launching emotime gui! Smile :) OpenCV Error: Sizes of input arguments do not match (The sample size is different from what has been used for training) in cvPreparePredictData,

I think both of the command launches /emotimegui_cli . Issue is that , its very slow . fps may be 1 .

  1. Can i reduce the image captured by the webcam. In my mac, its shown full screen! Will this help?
  2. Any other performance improvement tips?suggested?planned?
luca-m commented 9 years ago

I was able to reproduce your bug by using a non existent path for models:

./emotimegui_cli ../resources/haarcascade_frontalface_cbcl1.xml ../resources/haarcascade_eye.xml 52 52 1 5 8 svm ../DOESNOTEXISTS/dataset/svm_1vsallext_1_5_8_95c2eb0b58/*      

OpenCV Error: Bad argument (The SVM should be trained first) in CvSVM::predict, file /home/stk/bin/dev/opencv/opencv-2.4.9/modules/ml/src/svm.cpp, line 2131
terminate called after throwing an instance of 'cv::Exception'
  what():  /home/stk/bin/dev/opencv/opencv-2.4.9/modules/ml/src/svm.cpp:2131: error: (-5) The SVM should be trained first in function CvSVM::predict
luca-m commented 9 years ago

actually image size may impact performance of the face detection phase because some fixed values for face are specified in

65:     cascade_f.detectMultiScale(img, faces, 1.1, 2, 0|CV_HAAR_SCALE_IMAGE, this->faceMinSize );

which is 30x30 ..

I should tune it a bit..

crankdaworld commented 9 years ago

Hi Luca, Just wanted to check, does it track multiple face and their corresponding emotions?

Crankdaword

luca-m commented 9 years ago

at the moment the cli programs "tracks" only one face. Actually no tracking is performed because it is another kind of problem. If you'd like to track more faces you should you should add the replace the face simple face detector implemented here with a face detector and tracker, and then feed the other components will work transparently..

On 25 June 2015 at 11:36, MIA notifications@github.com wrote:

Hi Luca, Just wanted to check, does it track multiple face and their corresponding emotions?

Crankdaword

— Reply to this email directly or view it on GitHub https://github.com/luca-m/emotime/issues/48#issuecomment-115185960.

-lm

Kei404 commented 8 years ago

hi Luca, how can i save the predicted emotion into textfile?