How to use Shape Distance and Common Interfaces to find Hausdorff Distance in Opencv? -


i find hausdorff distance between 2 canny detector output image contains group of contours, find similarity of 2 shapes. need find hausdorff distance estimation. opencv has function implemented in it? i've found this link in opencv api reference cant find how use anywhere. please guide me how use functions?

there's nice sample on github this, 'll need opencv3.0 (master branch) use it.

actually , hausdorff distance not big mystery,

// internal helper: int distance_2( const std::vector<cv::point> & a, const std::vector<cv::point>  & b ) {     int maxdistab = 0;     (size_t i=0; i<a.size(); i++)     {         int minb = 1000000;         (size_t j=0; j<b.size(); j++)         {             int dx = (a[i].x - b[j].x);                  int dy = (a[i].y - b[j].y);                  int tmpdist = dx*dx + dy*dy;              if (tmpdist < minb)             {                 minb = tmpdist;             }             if ( tmpdist == 0 )             {                 break; // can't better equal.             }         }         maxdistab += minb;     }     return maxdistab; }  double distance_hausdorff( const std::vector<cv::point> & a, const std::vector<cv::point> & b ) {     int maxdistab = distance_2( a, b );     int maxdistba = distance_2( b, );        int maxdist = std::max(maxdistab,maxdistba);      return std::sqrt((double)maxdist); } 

Comments

Popular posts from this blog

html - Sizing a high-res image (~8MB) to display entirely in a small div (circular, diameter 100px) -

java - IntelliJ - No such instance method -

identifier - Is it possible for an html5 document to have two ids? -