detail code :
private LoaderCallbackInterface mLoaderCallback = new LoaderCallbackInterface() {
@Override
public void onManagerConnected(int status) {
if (status==LoaderCallbackInterface.SUCCESS){
...
ArrayList<Mat> mDataSetImages = new ArrayList<>();
ArrayList<Integer> mDataSetLabels = new ArrayList<>();
InputStream inputStream = getAssets().open("at.txt");
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream));
try {
String a = bufferedReader.readLine();
while (a!=null){
String[] s = a.split(";");
Mat mat = Imgcodecs.imread(s[0]);
mDataSetImages.add(mat);
mDataSetLabels.add(Integer.parseInt(s[1]));
a = bufferedReader.readLine();
}
inputStream.close();
bufferedReader.close();
trainImgWidth = mDataSetImages.get(0).cols();
trainImgHeight = mDataSetImages.get(0).rows();
Log.e(TAG, "getContentFromFile: trainImgWidth = "+trainImgWidth );
Log.e(TAG, "getContentFromFile: trainImgHeight = "+trainImgHeight );
int labs = new int[mDataSetLabels.size()];
for (int i=0;i<mDataSetLabels.size();i++){
labs[i] = mDataSetLabels.get(i);
}
} catch (IOException e) {
e.printStackTrace();
}
Mat mat = new Mat(labs.length(),1,CvType.CV_32S);
mat.put(0,0,labs);
faceRecognizer = FisherFaceRecognizer.create();
faceRecognizer.train(mDataSetImages,mat);
...
}
}
then ,error occur! The error points to the train method.
How can I solve it?
Caused by: CvException [org.opencv.core.CvException: cv::Exception: OpenCV(3.4.2-dev) ../../modules/core/src/matrix.cpp:830: error: (-13:Image step is wrong) The matrix is not continuous, thus its number of rows can not be changed in function 'cv::Mat cv::Mat::reshape(int, int) const' ] at org.opencv.face.FaceRecognizer.train_0(Native Method) at org.opencv.face.FaceRecognizer.train(FaceRecognizer.java:133)