how to calculate and use cvMat mean value

巧了我就是萌 提交于 2019-12-13 11:53:08

问题


In the openCV cheat sheet (C++), I have found the matrix opration mean(). When I use it:

float myMatMean = mean( MyMat );

I get the error:

no suitable conversion function from "cv::Scalar" to "float" exists

What can I do in order to use this data?


回答1:


Thanks.

The problem was that although myMat was a 2D image. The return type was still a Scalar of size 4.

The solution was

cv:Scalar tempVal = mean( myMat );
float myMAtMean = tempVal.val[0];


来源:https://stackoverflow.com/questions/12687437/how-to-calculate-and-use-cvmat-mean-value

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!