function print 0 all the time?
I am trying write a simple function that outputs the standard deviation of a cloud of points, but for some dumb reason it keeps outputting, 0.. Why?
Here is the code..
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
|
bool std_dev(vector<Point2f> points)
{
double Std_dev;
Point2f mean = Mean(points);
for(int i = 0; i < points.size(); i++)
{
Std_dev += pow(euclideanDistance(points[i]-mean),2);
}
//cout << "Std_dev: "<< Std_dev << endl;
Std_dev = Std_dev*(1/points.size());
Std_dev = sqrt(Std_dev);
cout << "Std_dev: "<< Std_dev << endl;
return true; //Threshold has to be added to know when it should re init the goodFeaturesToTrack Function.
}
double euclideanDistance(Point2f point1)
{
double match=0;
match += sqrt((point1.x - 0) * (point1.x - 0)+ (point1.y - 0) * (point1.y - 0));
//cout << "eucliadian distance: " << match << endl;
return match;
|
> Std_dev = Std_dev*(1/points.size());
integer division returns an integer
Topic archived. No new replies allowed.