Lauszus / FaceRecognitionApp

Face Recognition Android App
GNU General Public License v2.0
507 stars 238 forks source link

Crop Face Images #21

Closed safi099 closed 6 years ago

safi099 commented 6 years ago

For better recognition I cropped the face of the person. https://github.com/safi099/Face_Recognition/blob/master/app/src/main/java/com/developer/iamsafi/face_recognition/FaceOverLay.java

Firstly I convert the Mat mGray to Bitmap and then perform operation to crop the face and there for the images Array I again convert into Mat format of mGray using the following code. mGray = new Mat(scale.getHeight(), scale.getWidth(), CvType.CV_8U); Bitmap bmp32 = scale.copy(Bitmap.Config.ARGB_8888, true); Utils.bitmapToMat(bmp32, mGray) Images is properly cropped but when I train the error comes the Image must be 8 bit matrix from the native class train class. Please Help me to sort out the problem

safi099 commented 6 years ago

Also Tell me about the eigen faces that how many training images are sufficent and what value of face threshold and distance threshold it will give better results.

Lauszus commented 6 years ago

My guess would be that the created bitmap has more than one channel, so when the you convert it back to a Mat object, then it is not a grayscale image.

Try this code instead:

if (scale != null) {
    Mat origMat = new Mat();
    Bitmap bmp32 = scale.copy(Bitmap.Config.ARGB_8888, true);
    Utils.bitmapToMat(bmp32, origMat);
    Imgproc.cvtColor(origMat, mGray, Imgproc.COLOR_RGB2GRAY);
}
Lauszus commented 6 years ago

Please read the following papers: http://www.face-rec.org/algorithms/PCA/jcn.pdf and https://cseweb.ucsd.edu/classes/wi14/cse152-a/fisherface-pami97.pdf.

And my reports: https://github.com/Lauszus/FaceRecognitionLib/blob/master/Eigenfaces_Report.pdf and https://github.com/Lauszus/FaceRecognitionLib/blob/master/Final_Project_Report.pdf.

safi099 commented 6 years ago

I solved the issue of face cropping now it properly train data. but did not recognize the image properly. Actually I do not have understanding of eigen faces and PCA concepts so in order to understand I read the mentioned Papers but did not get my answer. So please do one favour that using Eigen faces what values I can set for these variables. How many train images = ? FaceThreshold values =? DistanceThreshold value =?

Please Answer me. I am very thankful to you. Thanks

safi099 commented 6 years ago

??

Lauszus commented 6 years ago

The number of training images are simply limited, as the app became quite slow on old devices. If you have a modern phone, then you can set it quite high.

If there was a magic constant value for the distances that worked for all scenarios, then I would have hard-coded them. You need to experiment with the values yourself to find what suit your needs.