Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Strange behavior short simple code with cv::Point and a references

That simple code leads 20 error in xutility file, and when I had commented temp = distance(p, pi), then solution successfully built. How to fix code; and why did errors appear?

P.S. static analyzer tells me about type pi : cv::Point_<int> pi, is that relates to the problem?

typedef vector<cv::Point> Points;

double distance (cv::Point& p1, cv::Point& p2) 
{
    return sqrt( pow( p1.x - p2.x,2) + pow( p1.y - p2.y,2));
}

double distance (cv::Point& p, Points& ps) 
{
     double d = numeric_limits<double>::max();
     double temp;

     for (auto pi: ps) 
     {
          temp = distance(p, pi);
          if (temp < d) d = temp;
     }
     return d;
}
click to hide/show revision 2
retagged

updated 2014-03-05 09:06:01 -0600

berak gravatar image

Strange behavior short simple code with cv::Point and a references

That simple code leads 20 error in xutility file, and when I had commented temp = distance(p, pi), then solution successfully built. How to fix code; and why did errors appear?

P.S. static analyzer tells me about type pi : cv::Point_<int> pi, is that relates to the problem?

typedef vector<cv::Point> Points;

double distance (cv::Point& p1, cv::Point& p2) 
{
    return sqrt( pow( p1.x - p2.x,2) + pow( p1.y - p2.y,2));
}

double distance (cv::Point& p, Points& ps) 
{
     double d = numeric_limits<double>::max();
     double temp;

     for (auto pi: ps) 
     {
          temp = distance(p, pi);
          if (temp < d) d = temp;
     }
     return d;
}