#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;
}
Eigenface.jpg 的尺寸为 (9x2304)。当我与图像相乘时,我面临这个错误,任何人都可以帮忙吗?
最佳答案
请检查矩阵 M1,M2 M1.列==M2.行。 如果它们不相等,则无法进行乘法!
关于opencv - cv::gemm 中断言失败 (a_size.width == len),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25377628/