【问题标题】:OpenCV Error: Assertion failed -- matrix subtractOpenCV 错误:断言失败——矩阵减法
【发布时间】:2018-01-10 16:37:29
【问题描述】:

我必须遵循带参数的矩阵:-

cv::Mat fFuncv--> size of fFunc [924440 x 10] and depth 5 

cv::Mat Ones -->size of Ones [924440 x 1] and depth 5

cv::Mat cFuncv-->size of cFunc [1 x 10] and depth 5

当我这样做时:-

d = fFunc - Ones * cFunc;

我收到以下错误消息

OpenCV 错误:

gemm 中的断言失败 (a_size.width == len),文件 D:\opencv\sources\modules\core\src\matmul.cpp,第 1537 行 在抛出 'cv::Exception' 的实例后调用终止 what(): D:\opencv\sources\modules\core\src\matmul.cpp:1537: 错误: (-215) a_size.width == len in function gemm

如果我执行另一个减法方法,比如

cv::subtract(fFunc,Ones*cFunc,d);

OpenCV 错误:

在 arithm_op,文件 D:\opencv\sources\modules\core\src\arithm.cpp,行中的断言失败 (type2 == CV_64F && (sz2.height == 1 || sz2.height == 4)) 661 在抛出 'cv::Exception' 的实例后调用终止 what(): D:\opencv\sources\modules\core\src\arithm.cpp:661: 错误: (-215) type2 == CV_64F && (sz2.height == 1 || sz2.height == 4)在函数 arithm_op 中

你能帮我看看错误信息是什么意思吗?我哪里错了?

【问题讨论】:

  • 代码第二行有错字。它应该是 cv::Mat。也许那是导致错误的原因。
  • @MarKS 是的,它就在这里,在代码中是正确的。

标签: c++ opencv matrix subtraction


【解决方案1】:

我相信大小是[Width,Height],即[num_cols,num_rows],所以你不能乘以 Ones * cFunc,而是cFunc * Ones

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-07-14
    • 1970-01-01
    • 1970-01-01
    • 2018-05-20
    • 2017-10-26
    • 2016-11-27
    • 2019-12-04
    相关资源
    最近更新 更多