警告C4244:'初始化':从'double'转换为'float',可能会丢失数据。转换在哪里?

时间:2015-06-29 09:14:36

标签: c++ opencv visual-studio-2013

我使用OpenCV函数编写了一个C ++代码,如下所示:

string mattype = findmattype(wxyz.type());
cout << "Type of wxyz: " << mattype.c_str() << endl;

Mat LastRowWeight = wxyz.row(rows - 1);
cout << "LastRowWeight =\n" << LastRowWeight << endl;
string mattype1 = findmattype(LastRowWeight.type());
cout << "Type of LastRowWeight: " << mattype1.c_str() << endl;
float LastRowSum = sum(LastRowWeight)[0];

输出显示如下:

Portion of the output window

对于代码的最后一行,我在构建解决方案时收到警告:警告C4244:'初始化':从'double'转换为'float',可能会丢失数据。我看过用户报告此错误的其他帖子,但在这些情况下,错误的原因对我来说很清楚。

对于我的情况,LastRowWeight的类型是32FC1或float,那么从double转换到哪里?即使输入Mat对象是float类型,函数'sum'是否输出一个double值(与[0]一起使用时)?请指导,因为我是OpenCV和C ++的新手。

P.S。 findmattype取自How to find out what type of a Mat object is with Mat::type() in OpenCV

0 个答案:

没有答案