Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
在 openCV 备忘单(C++)中,我找到了矩阵运算mean()。当我使用它时:
mean()
float myMatMean = mean( MyMat );
我得到错误:
不存在从“cv::Scalar”到“float”的合适转换函数
我该怎么做才能使用这些数据?
谢谢。
问题是虽然myMat是 2D 图像。返回类型仍然是Scalar大小为4的 a 。
myMat
Scalar
解决方案是
cv::Scalar tempVal = cv::mean( myMat ); float myMAtMean = tempVal.val[0];