Ask Your Question

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

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

Flart gravatar image

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

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

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

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

That error is caused due to your function name "distance" is conflict with some functions having the same name from std (see more at 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
Login/Signup to Answer

Question Tools


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

Seen: 198 times

Last updated: Mar 05 '14