title: How to access opencv contour point indexes in python?
body: <p>Is there way to access the <code>contour[i][j]</code> in python?</p>
  
  <p>I am struggling to translate this c++ into python, because the data structures are different. It's being hard making comparisions</p>
  
  <pre><code>static double distanceBtwPoints(const cv::Point a, const cv::Point b)
  {
       double xDiff = a.x - b.x;
       double yDiff = a.y - b.y;
  
       return std::sqrt((xDiff * xDiff) + (yDiff * yDiff));
  }
  
  static int findNearestPointIndex(const cv::Point pt, const vector&lt;Point&gt; points)
  {
      int nearestpointindex = 0;
      double distance;
      double mindistance = 1e+9;
  
      for ( size_t i = 0; i &lt; points.size(); i++)
      {
          distance = distanceBtwPoints(pt,points[i]);
  
          if( distance &lt; mindistance )
          {
              mindistance =  distance;
              nearestpointindex = i;
          }
      }
      return nearestpointindex;
  }
  
  int main( int argc, char** argv )
  {
      Point pt0;
      int shift=0; // optional value for drawing scaled
      Scalar color = Scalar(0,0,0);
  
      char* filename = argc &gt;= 2 ? argv[1] : (char*)"test.png";
      Mat img = imread(filename);
      if (img.empty())
          return -1;
  
      vector&lt;vector&lt;Point&gt; &gt; contours;
      vector&lt;Point&gt; contour;
      findContours( bw, contours, CV_RETR_EXTERNAL, CV_CHAIN_APPROX_NONE );
  
      contour = contours[0];
      for ( size_t i = 0; i &lt; contours.size(); i++)
      {
          if( contour.size() &lt; contours[i].size() )
              contour = contours[i];
      }
  
      for ( size_t i = 0; i &lt; contours.size(); i++)
      {
          if( contour != contours[i] &amp;&amp; contours[i].size() &gt; 10 )
          {
              for ( size_t j = 0; j &lt;  contours[i].size(); j++)
              {
                  pt0 = contours[i][j];
                 line(src,pt0,contour[findNearestPointIndex(pt0,contour)],color,1,LINE_8,shift);
              }
          }
      }
  }
  </code></pre>
  
  <p>Thank you for the patient and answers.</p>