Sum of elements in a matrix in OpenCV?
In addition with @Shai you can use;
double sum = cv::sum(A).val(0);
Unlike Matlab, in opencv, cv::sum(A)
sums along ALL dimensions and returns a single number (scalar) that is equal to Matlab's sum(sum(A))
.
So, what you need is
double s = cv::sum(A)[0];