Ask Your Question
0

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

asked 2014-03-05 09:00:43 -0600

Flart gravatar image

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

berak gravatar image

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;
}
edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
2

answered 2014-03-05 11:03:16 -0600

updated 2014-03-05 11:14:35 -0600

That error is caused due to your function name "distance" is conflict with some functions having the same name from std (see more at http://stackoverflow.com/questions/4217733/distance-calculation-error-in-c). To solve that, simply change your function names to "mydistance" (or some other names) or remove statement "using namespace std;" from you file scope, just using what you exactly need from std namespace.

edit flag offensive delete link more

Question Tools

Stats

Asked: 2014-03-05 09:00:43 -0600

Seen: 290 times

Last updated: Mar 05 '14