I have the following code:
Scalar m; //Scalar is a class for a 4 variable vector. m is its instance.
Scalar std;
meanStdDev(hist, m, std);
It works well but it doesn't work for the following.
vector < float > m;
vector < float > std;
meanStdDev(hist, m, std);
I am not able to understand the problem as here also I am creating a vector just like in the case of Scalar. Please explain.
2 problems here:
1) it needs something with a fixed size.
2) your vectors are initially empty
you can use a Scalar, a (pre-allocated) Mat, or a Vec4d, but not a std::vector.
Mat hist(10,1,CV_32F);
randu(hist,1,100);
cerr << hist << endl;
{
Scalar m, stdv;
meanStdDev(hist, m, stdv);
cerr << m << " " << stdv << endl;
}
{
Mat m(1,4,CV_64F),stdv(1,4,CV_64F);
meanStdDev(hist, m, stdv);
cerr << m << " " << stdv << endl;
}
{
Vec4d m,stdv;
meanStdDev(hist, m, stdv);
cerr << m << " " << stdv << endl;
}
[53.497997;
20.72666;
40.704884;
81.624123;
44.276165;
25.63018;
77.537399;
76.447281;
31.471653;
70.540741]
[52.2457, 0, 0, 0] [21.8056, 0, 0, 0]
[52.245703125] [21.80564409388921]
[52.2457, 0, 0, 0] [21.8056, 0, 0, 0]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With