title: How to Process Coordinates for OpenCV Contours?
body: <p>I have an image like here below:</p>
  
  <p><img src="https://i.imgur.com/gN7vG4Y.jpg?1" alt="Braille"></p>
  
  <p>With this source code, I have successfully extract the center coordinates of each dots in the image.</p>
  
  <pre><code>#include &lt;opencv2/imgproc/imgproc.hpp&gt;
  #include &lt;opencv2/highgui/highgui.hpp&gt;
  #include &lt;opencv/cv.h&gt;
  #include &lt;iostream&gt;
  #include &lt;vector&gt;
  
  int main(int argc, char **argv)
  {
      cv::Mat matSrc,matTmp,matDst;
      cv::Mat matV,matROI;
      std::vector&lt;cv::Mat&gt; vectorHSV;
      std::vector&lt;std::vector&lt;cv::Point&gt; &gt; contours;
      std::vector&lt;cv::Vec4i&gt; hierarchy;
      matSrc = cv::imread(argv[1],1);
  //    matSrc = cv::imread("123.jpg",1);
  //    cv::imshow("Source", matSrc);
      cv::cvtColor(matSrc,matTmp,CV_RGB2HSV);
      cv::split(matTmp,vectorHSV);
      matV = vectorHSV[2];
      matV.copyTo(matTmp);
      cv::normalize(matTmp,matTmp,0,255,CV_MINMAX,CV_8UC1);
      cv::medianBlur(matTmp,matTmp,5);
      cv::adaptiveThreshold(matTmp,matTmp,255,CV_ADAPTIVE_THRESH_GAUSSIAN_C,CV_THRESH_BINARY_INV,125,7);
      cv::equalizeHist(matTmp,matTmp);
  //    cv::erode(matTmp,matTmp,cv::getStructuringElement(cv::MORPH_RECT, cv::Size(3,3)));
      cv::morphologyEx(matTmp,matTmp,cv::MORPH_CLOSE,cv::getStructuringElement(cv::MORPH_RECT, cv::Size(3,3)));
      cv::Canny(matTmp,matTmp,50,150,3);
      cv::Rect ROI(0,0,matTmp.cols,matTmp.rows); 
      matROI = matTmp(ROI);
      cv::findContours(matROI,contours,hierarchy,CV_RETR_EXTERNAL,CV_CHAIN_APPROX_TC89_KCOS,cv::Point(0,0));
      std::vector&lt;cv::Moments&gt; muDots(contours.size());
      std::vector&lt;cv::Point&gt; mcDots(contours.size());
      for(size_t c=0;c &lt; contours.size();c++)
      {
          muDots[c] = cv::moments(contours[c],false);
          mcDots[c] = cv::Point(static_cast&lt;int&gt;(muDots[c].m10/muDots[c].m00) , static_cast&lt;int&gt;(muDots[c].m01/muDots[c].m00));
      }
      for(int allDots=0;allDots &lt; mcDots.size();allDots++)
      {
          std::cout &lt;&lt; allDots &lt;&lt; ": " &lt;&lt; mcDots[allDots].x &lt;&lt; "," &lt;&lt; mcDots[allDots].y &lt;&lt; std::endl;
      }
  
      matTmp.copyTo(matDst);
      imshow("ROI",matROI);
  //    imshow("Result", matDst);
      cv::waitKey(0);
      return 0;
  }
  </code></pre>
  
  <p>What I want to ask is how to process the contours if it exist or not, in short description I want to do like in this algorithm:</p>
  
  <pre><code>for(x=0;x &lt; Image.cols;x++)
      {
          for(y=0;y &lt; Image.rows;y++)
          {
              if(Contour coordinates at X,Y = Exist)
              {
                   vectorBraille.push_back = 1;
              }
              else
              {
                   vectorBraille.push_back = 0;
               } 
          }
      }
  </code></pre>
  
  <p>Please, I really need suggestion for this problem, I'm a little bit stuck in here.</p>
  
  <p>Any help would be very appreciated.
  Thank you</p>