Is there some openCV function that I can pass in a cv::Mat
and get the sum of all values in them?
For example: int cvSumFoo(Mat &srcMat)
; I'm expecting an int to come back
I create it like this:
srcMat= new Mat(rows, cols, CV_8U);
I would like to avoid creating my own loop if at all possible.
The function 'sum' "calculates and returns the sum of array elements, independently for each channel."
You can find the information here: http://docs.opencv.org/modules/core/doc/operations_on_arrays.html#sum
I know that the questioner didn't ask for the function in Java-openCV, but I still want to show how to do it in Java, because:
The code for printing a sum in Java openCV is:
Obvious is that, it is not a function of the "Scalar"-class and its name is not
sum()
.