Android Error :Fatal signal 11 (SIGSEGV) at 0x760f1011 (code=1), thread 11933 [closed]
The above is a common Bug in Android and I found in numerous places and most of the places recommended a solution of cleaning the memory.
Issue thrown at train method. faceRecognizer.train(images, labels);
https://groups.google.com/forum/#!topic/javacv/tniCCfSyg4c
I've tried all solution to solve the problem in Android but nothing worked, but same thing is fine in System\PC because of more memory and process I guess , if thats the reason The Code Sample-
import static com.googlecode.javacv.cpp.opencv_contrib.createEigenFaceRecognizer;
import static com.googlecode.javacv.cpp.opencv_core.IPL_DEPTH_8U;
import static com.googlecode.javacv.cpp.opencv_highgui.cvLoadImage;
import static com.googlecode.javacv.cpp.opencv_imgproc.CV_BGR2GRAY;
import static com.googlecode.javacv.cpp.opencv_imgproc.cvCvtColor;
import static com.googlecode.javacv.cpp.opencv_core.*;
import static com.googlecode.javacv.cpp.opencv_imgproc.*;
import java.io.File;
import java.io.FilenameFilter;
import java.util.ArrayList;
import java.util.List;
import android.os.Environment;
import android.util.Log;
import com.googlecode.javacv.cpp.opencv_contrib.FaceRecognizer;
import com.googlecode.javacv.cpp.opencv_core.IplImage;
import com.googlecode.javacv.cpp.opencv_core.MatVector;
public class OpenCVFaceRecognizer {
static List<File> pathList = new ArrayList<File>();
//pictureFile.getAbsolutePath()
public static int verifyFace(String strTestImage){
IplImage testImage = cvLoadImage(strTestImage);
Log.i("testImagetestImage ", testImage.toString());
String path = Environment.getExternalStorageDirectory().toString()
+ "/FaceR_DB/FaceDB";
Log.i("PATH 2", path);
File root = new File(path);
if(pathList != null && pathList.size()>0){
pathList.clear();
}
if(!root.exists() || !root.isDirectory()){
return -1;
}
List<File> listFilesForFolder = listFilesForFolder(root);
FilenameFilter pngFilter = new FilenameFilter() {
public boolean accept(File dir, String name) {
return name.toLowerCase().endsWith(".png");
}
};
Log.i("SIZEEEEEEee", ""+listFilesForFolder.size());
if(listFilesForFolder.size()<1){
return -1;
}
MatVector images = new MatVector(listFilesForFolder.size());
int[] labels = new int[listFilesForFolder.size()];
int counter = 0;
int label;
IplImage img;
IplImage grayImg;
for (File image : listFilesForFolder) {
// Get image and label:
img = cvLoadImage(image.getAbsolutePath());
String[] split = image.getName().split( "\\." );
// System.out.println("NAME "+);
label = Integer.parseInt(image.getName().split("\\.")[0]);
// Convert image to grayscale:
grayImg = IplImage.create(img.width(), img.height(), IPL_DEPTH_8U, 1);
cvCvtColor(img, grayImg, CV_BGR2GRAY);
// Append it in the image list:
images.put(counter, grayImg);
// And in the labels list:
labels[counter] = label;
Log.i("labels ", ""+labels+" img "+img);
//img.release();
cvReleaseImage(img); // tried both separately or together, still doesn't work\
// img = null;
System.gc();
// Increase counter for next image:
counter++;
Log.i("RELEASE ", "Released "+counter);
}
FaceRecognizer faceRecognizer = createEigenFaceRecognizer();
Log.i("After images", ""+images.size()+" labels "+labels.length+" faceRecognizer "+faceRecognizer);
faceRecognizer.train(images, labels);
Log.i("PROJECTIOn ", "-- "+faceRecognizer.getDouble( "threshold" ));
faceRecognizer.set( "threshold", 10000 );
//get the MAT : projectedTrainFaceMat LINE 700
//CvMat mat = faceRecognizer.getMat( testImage.gto );
// faceRecognizer.save("C:\\Users\\choudhar\\Bunta_DB\\fisherface_at.yml");
// CvMat eigenvalues = faceRecognizer.getMat("eigenvalues");
//CvMat W = faceRecognizer.getMat("eigenvectors");
//CvMat mean = faceRecognizer.getMat("mean");
// Load the test image:
IplImage greyTestImage = IplImage.create(testImage.width(), testImage.height(), IPL_DEPTH_8U, 1);
cvCvtColor(testImage, greyTestImage, CV_BGR2GRAY);
// And get a prediction:
// faceRecognizer.predict( greyTestImage, labels, new double[] {0.5} );
return ...