Advertisement
matrefeytontias

Untitled

Feb 18th, 2018
404
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.27 KB | None | 0 0
  1. void CorrectionAlg::updateFailedCentroid(CorrectionData & c, int counter, double x0, double y0, double x1, double y1, double x2, double y2)
  2. {
  3.     std::vector<int> indices(3);
  4.     // "Sort" the centroids along increasing Y
  5.     if(y0 < y1)
  6.     {
  7.         if(y1 < y2)
  8.             indices = { 0, 1, 2 };
  9.         else // y2 < y1
  10.         {
  11.             if(y0 < y2)
  12.                 indices = { 0, 2, 1 };
  13.             else // y2 < y0
  14.                 indices = { 2, 0, 1 };
  15.         }
  16.     }
  17.     else // y1 < y0
  18.     {
  19.         if(y0 < y2)
  20.             indices = { 1, 0, 2 };
  21.         else // y2 < y0
  22.         {
  23.             if(y1 < y2)
  24.                 indices = { 1, 2, 0 };
  25.             else // y2 < y1
  26.                 indices = { 2, 1, 0 };
  27.         }
  28.     }
  29.  
  30.     std::cout << x0 << ", " << y0 << std::endl;
  31.     std::cout << x1 << ", " << y1 << std::endl;
  32.     std::cout << x2 << ", " << y2 << std::endl;
  33.     std::cout << indices[0] << indices[1] << indices[2] << std::endl;
  34.  
  35.     Mat centroids(3, 2, CV_32S);
  36.     centroids.at<double>(0, 0) = x0;
  37.     centroids.at<double>(0, 1) = y0;
  38.     centroids.at<double>(1, 0) = x1;
  39.     centroids.at<double>(1, 1) = y1;
  40.     centroids.at<double>(2, 0) = x2;
  41.     centroids.at<double>(2, 1) = y2;
  42.     fillCstruct(c, counter, indices, centroids);
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement