简体   繁体   English

OpenCV错误:断言

[英]OpenCV Error: Assertion

Mat m1 = Mat(500, 300, CV_64F, Vec3b(255,255,255));
  for (int i = 0; i < m1.rows; ++i)
    for (int j = 0; j < m1.cols; ++j)
    {
        Vec3b color=m1.at<Vec3b>(Point(i, j));
    }
imshow("test2", m1);
waitKey();

The variable color should contain the color of the pixel which is white but i when i run the code i get the error: 可变的颜色应该包含白色的像素的颜色,但是当我运行代码时出现错误:

OpenCV Error: Assertion failed (((((sizeof(size_t)<<28)|0x8442211) >> ((traits::Depth<_Tp>::value) & ((1 << 3) - 1))*4) & 15) == elemSize1()) in cv::Mat::at, file c:\\opencv\\build\\include\\opencv2\\core\\mat.inl.hpp, line 1118 OpenCV错误:断言失败((((((sizeof(size_t)<< 28)| 0x8442211)>>((traits :: Depth <_Tp> :: value)&((1 << 3)-1))* 4 )&15)== elemSize1())在cv :: Mat :: at中,文件c:\\ opencv \\ build \\ include \\ opencv2 \\ core \\ mat.inl.hpp,第1118行

The error message is telling you what you need to know. 错误消息告诉您您需要了解的内容。 You've gone out of bounds! 您已经超出范围!

Try: 尝试:

Point(j, i)

Columns correspond to x . 列对应于x Rows correspond to y . 行对应于y

try this 尝试这个

Mat m1 = Mat(500, 300, CV_64F, Vec3b(255,255,255));
  for (int i = 0; i < m1.rows; ++i)
    for (int j = 0; j < m1.cols; ++j)
    {
        Vec3b color=m1.at<Vec3b>(i, j);//changed
    }
imshow("test2", m1);
waitKey();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM