Wrong Shapes for Given Matrices in OpenCv 3.1 - Java
I have trained the FaceRecognizer all the images are of same size and passed the grayscale image to the predictor. But i face this error
OpenCV Error: Bad argument (Wrong shapes for given matrices. Was size(src) = (1,150544), size(W) = (37636,5).) in subspaceProject, file /home/**/opencv/modules/core/src/lda.cpp, line 182
Here is the code
if (videoDevice.isOpened()) {
while (true) {
Mat frameCapture = new Mat();
videoDevice.read(frameCapture);
MatOfRect faces = new MatOfRect();
cascadeFaceClassifier.detectMultiScale(frameCapture, faces, 2.0, 5, 0,new Size(),new Size());
for (Rect rect : faces.toArray()) {
Mat resizedCapture = new Mat(frameCapture,rect);
Imgproc.cvtColor(resizedCapture, resizedCapture, Imgcodecs.CV_LOAD_IMAGE_GRAYSCALE);
Size imageSize = new Size(194,194);
Imgproc.resize(resizedCapture,resizedCapture , imageSize);
System.out.println(images.get(0).rows());
System.out.println(resizedCapture.rows());
System.out.println(images.get(0).cols());
System.out.println(resizedCapture.cols());
try{
x = faceRecognizer.predict_label(resizedCapture);
}catch(Exception e){
System.out.println(e.getMessage());
}
x++;
Imgproc.putText(frameCapture, "Face"+x, new Point(rect.x,rect.y-5), 1, 2, new Scalar(0,0,255));
Imgproc.rectangle(frameCapture, new Point(rect.x, rect.y), new Point(rect.x + rect.width, rect.y + rect.height),new Scalar(0, 100, 0),3);
}
PushImage(ConvertMat2Image(frameCapture));
//System.out.println(String.format("FACES = %s EYES = %s detected.", faces.toArray().length,eyes.toArray().length,nose.toArray().length));
}