I want to calculate the mean and stdDev of a 2d vector using cv::meanStdDev
. But it keeps getting error. Here is an example of my code
vector<vector<uchar>> v = {{1,2,3}, {4,5,6}};
Scalar mean, stddev;
meanStdDev(v, mean, stddev);
OpenCV Error: Assertion failed (0 <= i && i < (int)vv.size()) in cv::_InputArray::getMat_, file C:\\build\\master_winpack-build-win64-vc14\\opencv\\modules\\core\\src\\matrix.cpp, line 1244
If I change it to 1d vector. It works
vector<uchar> v = {1,2,3};
Scalar mean, stddev;
meanStdDev(v, mean, stddev);
The document states that cv::meanStdDev
can take vector<vector<_T>>
as InputArray. What did I do wrong here? Much appreciated.
Nothing in your code/post indicates where that error actually occurs. Try wrapping the call in a try catch block, that may provide more information when you look at the exception in the debugger.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.