Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to calculate and use cvMat mean value

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?

like image 246
EyalG Avatar asked Oct 02 '12 09:10

EyalG


1 Answers

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 = cv::mean( myMat );
float myMAtMean = tempVal.val[0];
like image 156
EyalG Avatar answered Oct 04 '22 04:10

EyalG