Collectives™ on Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most.
Learn more about Collectives
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Learn more about Teams
#include <opencv2\core\core.hpp>
#include<opencv2\imgproc\imgproc.hpp>
#include<opencv2\highgui\highgui.hpp>
#include <iostream>
#include<conio.h>
using namespace cv;
using namespace std;
int main()
Mat im= imread("D:\\try.jpg"),newface,A;
Mat im2 = imread("D:\\project\\barc\\variables\\Eigenface.jpg");
cvtColor(im, im, CV_BGR2GRAY);
cvtColor(im2, im2, CV_BGR2GRAY);
resize(im, im, Size(48, 48));
newface = im.reshape(0, 2304);
newface.convertTo(newface, CV_32FC1);
im2.convertTo(im2, CV_32FC1);
cout << "Diff : " << newface.size() << "\t" << "channels" << newface.channels() << endl;
cout << "Eigen : " << im2.size() << "\t" << "channels" << im2.channels() << endl;
A = im2*newface.t();
_getch();
return 0;
The Eigenface.jpg is of dimension (9x2304). When i am multiplying with the image i am facing this error is coming can anyone help?
–
–
–
Print matrix width (cols) and height (rows) and see the problem: Eigenface.cols = 9
and diff_test_image.rows = 2304
. The two must be equal to do the multiplication. Do:
test_omega = (Eigenface.t())*diff_test_image;
Edit after code:
What does it prints in the line of cout << "Diff : " << newface.size() << "\t" << "channels" << newface.channels() << endl;
? What about the next one? Is the Eigenface.jpg
of size 9x2304
? I do not think so...
Even if im2.rows == 2304
, you are multiplying with a column vector that should be in front of im2
or just try newface = im.reshape(0, 1);
for having a column vector so it's transpose will be a row vector
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.