简体   繁体   English

OpenCV Mat :: at 537行断言失败错误

[英]OpenCV Mat::at line 537 Assertion Failed Error

I am getting an assertion failed error in line 537 of Mat::at 我在Mat :: at的537行中遇到断言失败错误

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:\\users\\tim\\document s\\code\\opencv\\build\\include\\opencv2\\core\\mat.hpp, line 537 OpenCV错误:断言失败(尺寸<= 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())在未知函数中,文件c:\\ users \\ tim \\ document s \\ code \\ opencv \\ build \\ include \\ opencv2 \\ core \\ mat.hpp,第537行

I am trying to populate matrices that I will use in the function cv::remap. 我正在尝试填充将在函数cv :: remap中使用的矩阵。 The part of the code that is causing this failed assertion is below: 导致此失败的断言的代码部分如下:

void Functions::PopulatedMapY(Mat image)
{
    mapy.create(image.rows, image.cols, CV_32FC1);
    for (int j = 0; j<image.rows; j++)
    {   
        float a = (image.rows - 1) - gazey;
        float b = (image.cols - 1) - gazex;
        for (int i = 0; i<image.cols; i++)
        {       
            mapy.at<float>(j,i) = map2y.at<float>(a+j,b+i);
        }   
    }
}

The matrix map2y was defined in the MapCreator Function as follows: 矩阵map2y在MapCreator函数中定义如下:

void Functions::MapCreator(Mat image, float const_a, float const_b)
{
    map2x.create(2*image.rows, 2*image.cols, CV_32FC1);
    map2y.create(2*image.rows, 2*image.cols, CV_32FC1);

    for (int m = 0; m<2*image.rows; m++)
    {
        ty = image.rows - m;
        for (int n = 0; n<2*image.cols; n++)
        {
            tx = image.cols - n;
            map2x.at<float>(m,n) = n;
            map2y.at<float>(m,n) = m +const_b*exp(-pow(tx,2)/pow(const_a, 2))*Signum(ty);

    }
    }

}

Any help would be much appreciated! 任何帮助将非常感激!

From your error code you can find that the assertion goes false after the Mat::at call and inside this method your code goes false if: 从错误代码中,您可以发现在Mat::at调用之后断言为假,并且在以下情况下,您的代码将为假:
a. 一种。 The nr. Nr。 of channels is less than 2. 的频道数少于2。
b. b。 data is null 数据为空
c. C。 (unsigned)i0 < (unsigned)size.p[0] (无符号)i0 <(无符号)size.p [0]
plus some others. 再加上其他一些。
My suggestion in your case is the nr. 我对您的建议是nr。 of channels. 渠道。 CV_32FC1 means like that: CV_32FC1的意思是这样的:
CV_< bit_depth > (S|U|F)C< nr_channels >. CV_ <位深度>(S | U | F)C <nr_channels>。 I suppose here is the problem, the template parameter or the data is null. 我想这是问题所在,模板参数或数据为空。
My solution just use CV_32F instead. 我的解决方案只是使用CV_32F代替。
As a big reference take a look here: 作为参考,在这里看看:
OpenCV Error: Assertion failed, mat.cpp line 537 OpenCV错误:断言失败,mat.cpp行537

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

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