从Mat读取值时出错

时间:2013-05-04 22:51:38

标签: opencv assertion mat

我正在尝试在opencv中实现HMM。 首先,我创建double数组,并将它们复制到Mat变量,

Mat INIT = Mat(0,3,CV_64F,trans).clone();

然后我试图从矩阵中访问单个像素/位置值:

cout << INIT.at<double>(r,c) << " ";//Where r and c are row and column values.

我收到的错误如下:

 OpenCV Error: Assertion failed (dims <= 2 && data && (unsigned)i0 < (unsigned)si
ze.p[0] && (unsigned)(i1*DataType<_Tp>::channels) < (unsigned)(size.p[1]*channel
s()) && ((((sizeof(size_t)<<28)|0x8442211) >> ((DataType<_Tp>::depth) & ((1 << 3
) - 1))*4) & 15) == elemSize1()) in unknown function, file c:\opencv2.4.4\includ
e\opencv2\core\mat.hpp, line 537

我搜索了论坛,但发现代码没有任何问题。有任何想法吗? 非常感谢。

1 个答案:

答案 0 :(得分:1)

将Matrix INIT声明为: -

Mat INIT=Mat(1,3,CV_64FC1,trans).clone();

现在从矩阵中访问各个像素/位置值:

cout << INIT.at<double>(r,c) << " ";