OpenCV: Getting the total of Mat values

c++, opencv

Solution

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

Problem

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.

Original source

Related problems