1 | initial version |
a roi does not have continuous memory, it is more a "view" into the original pixel array. (so your code gets the row offsets wrong)
please do not write for ... loops for this, instead use builtin opencv functions,
see it all boils down to a single (and safe !!) line:
Scalar mean = cv::mean(image_gray(roi));