gpt4 book ai didi

opencv - cv::gemm 中的断言失败(a_size.width == len)

转载 作者:太空宇宙 更新时间:2023-11-03 21:27:26 26 4
gpt4 key购买 nike

#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,M2M1.cols == M2.rows。如果它们不相等,则乘法是不可能的!

关于opencv - cv::gemm 中的断言失败(a_size.width == len),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25377628/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com