Qualeams / Android-Face-Recognition-with-Deep-Learning-Library

Face Recognition library for Android devices is an Android library (module) which includes several face recognition methods.
Apache License 2.0
371 stars 135 forks source link

Crash on face recognize method #3

Closed mjhassan closed 7 years ago

mjhassan commented 7 years ago

Hi, There is a crash when I try to recognize face using Eigenfaces algorithm. The crash is in public String recognize(Mat img, String expectedLabel) method; to be more specific at the following line:

Core.subtract(img, Psi, img);

Here's error log:

CvException [org.opencv.core.CvException: cv::Exception: /Volumes/Linux/builds/master_pack-android/opencv/modules/core/src/arithm.cpp:639: error: (-209) The operation is neither 'array op array' (where arrays have the same size and the same number of channels), nor 'array op scalar', nor 'scalar op array' in function void cv::arithm_op(cv::InputArray, cv::InputArray, cv::OutputArray, cv::InputArray, int, void (*)(const uchar, size_t, const uchar, size_t, uchar, size_t, int, int, void), bool, void, int) ] at org.opencv.core.Core.subtract_2(Native Method) at org.opencv.core.Core.subtract(Core.java:2083) at ch.zhaw.facerecognitionlibrary.Recognition.Eigenfaces.recognize(Eigenfaces.java:77) at com.infolytx.facerecognizer.RecognitionActivity.onCameraFrame(RecognitionActivity.java:142) at org.opencv.android.CameraBridgeViewBase.deliverAndDrawFrame(CameraBridgeViewBase.java:389) at org.opencv.android.JavaCameraView$CameraWorker.run(JavaCameraView.java:357) at java.lang.Thread.run(Thread.java:841)

Would you please help me to solve it? Thanks.

sladomic commented 7 years ago

Hi,

Seems that either img or Psi is corrupt at that point. Did you train the Eigenfaces algorithm first? You could check if the file /sdcard/Pictures/facerecognition/data/Eigenfaces/eigenfaces.xml contains the matrix Psi which should have 625 cols if you use N=25 (25x25=625).

sladomic commented 7 years ago

Another problem could be with the img (which is the preprocessed image where you want to recognize someone). If the preprocessing fails at one point, the img will be null.

mjhassan commented 7 years ago

thanks for your reply. yes, I did train Eigenface algorithm first. I'll check the eigenfaces.xml file. How do I check if the preprocessing fails?

sladomic commented 7 years ago

Try to debug before entering the subtract function. Then paste an image here of the variables Psi and img (or use Psi.dump() and img.dump() to log the whole Mat object)

sladomic commented 7 years ago

Hi @mjhassan , any update?