I'm very new to OpenCV, so I guess I'm making some silly mistake.
First I'm creating an empty cv::mat
matrix, mask
, of CV_8U
type and filling it with zeros. Then I'm filling the matrix with either 0's or 255's by checking the values in CV_32FC1
type cv::mat
matrix croppedDifferenceImage
by the use of cv::threshold
. Then I'm using mask
as a parameter for cv::mean
function.
cv::Mat mask = cv::Mat(croppedDifferenceImage.rows, croppedDifferenceImage.cols, CV_8U, cv::Scalar(0));
cv::threshold(croppedDifferenceImage, mask, 3.2, 255, CV_THRESH_BINARY);
double mean = cv::mean(croppedDifferenceImage, mask)[0];
But I keep having a crash with the message:
/build/buildd/opencv-2.4.8+dfsg1/modules/core/src/stat.cpp:565: error: (-215) mask.empty() || mask.type() == CV_8U in function mean
What am doing wrong?