Mat OpenCv的赋值错误
assignment error with Mat OpenCv
我正在使用OpenCV和c++进行一个项目,我发现了以下问题:在用以下语句初始化mat后
Mat or_mat=Mat(img->height,img->width,CV_32FC1);
检查以下值
or_mat.at <float> (i, j) = atan (fy / fx) / 2 +1.5707963;
在完成返回函数输出的垫子之后,但是当我去读取时,有许多值与输出不对应。插入I-4.31602e +008的不正确的精确值,如果我使cout
,则表达式的值是正确的。错误是什么?
Mat or_mat=Mat(img->height,img->width,CV_32FC1);
to angle
if(fx > 0){
or_mat.at<float>(i,j) = atan(fy/fx)/2+1.5707963;
}
else if(fx<0 && fy >0){
or_mat.at<float>(i,j) = atan(fy/fx)/2+3.1415926;
}
else if(fx<0 && fy <0){
or_mat.at<float>(i,j) = atan(fy/fx)/2;
}
else if(fy!=0 && fx==0){
or_mat.at<float>(i,j) = 1.5707963;
}
我必须计算指纹图像的局部方向,下面的代码我省略了几个没有错误的语句和计算。
我会再三检查你的索引是否正确。下面的代码显示了我初始化一个满是零的矩阵,然后用.at
操作符填充它。它可以很好地编译和运行:
int main()
{
int height = 10;
int width = 3;
// Initialise or_mat to with every element set to zero
cv::Mat or_mat = cv::Mat::zeros(height, width, CV_32FC1);
std::cout << "Original or_mat:n" << or_mat << std::endl;
// Loop through and set each element equal to some float
float value = 10.254;
for (int i = 0; i < or_mat.rows; ++i)
{
for (int j = 0; j < or_mat.cols; ++j)
{
or_mat.at<float>(i,j) = value;
}
}
std::cout << "Final or_mat:n" << or_mat << std::endl;
return 0;
}
相关文章:
- 错误:在为指针赋值时,void值没有被忽略
- 使用 mat.at<uchar>(i,j) 的 opencv C++中的矩阵赋值错误
- 奇怪的 G++ 错误,带有关于左值和赋值的简单代码
- 重载赋值运算符函数和复制构造函数中的错误
- 当我尝试构建此程序时,出现此错误:需要左键作为赋值的左操作数
- 错误:无法在赋值中将"双 ()(双)抛出 ()"转换为"双倍"
- 错误消息:使用复制构造函数和重载赋值运算符
- 为什么在取消引用的指向接口的指针上使用赋值运算符不是编译器错误
- 如何重载 const 对象的 [],以便值赋值不会导致编译错误
- C++的新增功能:创建 2D 数组并具有正确的赋值运算符:分割错误
- C++:构造函数中的向量赋值错误
- 使用赋值运算符复制两个类中的数组时出现编译器错误
- 可以错误地使用赋值运算符而不是比较运算符的地方,= Vs ==
- 唯一指针中的赋值运算符错误
- 不断增加的指针数组 错误:赋值中的类型不兼容
- C++赋值构造函数瓦尔格林德错误
- { } 构造函数实现中的赋值运算符 => 错误
- 使用宏进行赋值和错误检查
- 两个向量赋值错误
- 错误:在 GEANY 中将"int"赋值为"char [1]"时类型不兼容