I am trying to perform facial recogntion using opencv. For this the training and test images have to be of the same size.
So I used this function:
resize(testing,output, images[0].size(),0,0,INTER_NEAREST);
Where testing is my Mat from the webcam , Output is the resized image , images[0].size() is my database of vector images.
However I get the following error:
OpenCV Error: Bad argument (Wrong shapes for given matrices. Was size(src) = (1,921600),
size(W) = (307200,6).) in subspaceProject,
file /home/someplae/OpenCV-2.4.2/modules/contrib/src/lda.cpp,
line 187
terminate called after throwing an instance of 'cv::Exception'
what(): /home/someplace/OpenCV-2.4.2/modules/contrib/src/lda.cpp:187:
error: (-5) Wrong shapes for given matrices. Was size(src) = (1,921600), size(W) = (307200,6).
in function subspaceProject
Although you don’t provide enough code to verify, I can infer the problem from the given number of elements. Your test matrix is
921600 = 3 * 307200… So I guess your input matrix is not a grayscale matrix, but still is in BGR representation.You should use cv::cvtColor to convert the matrix to grayscale, before resizing it: