title: Finding length of contour in opencv
body: <p>This is regarding a project that concerns detection of text in an image using OpenCV in C. The process is to detect the colors inside and outside the corresponding contours and the way to do that is to draw normals on the contours in equal spaced positions and extract the pixel colors in the corresponding positions of the normals end-points.</p>
  
  <p>I am trying to implement this using the following code but it's not working. I mean, its drawing the normals but not in and equi-spaced fashion.</p>
  
  <pre><code>for( ; contours!=0 ; contours = contours-&gt;h_next )
  {
          CvScalar color = CV_RGB( rand()&amp;255, rand()&amp;255, rand()&amp;255 );
  
          cvDrawContours( cc_color, contours, color, CV_RGB(0,0,0), -1, 1, 8, cvPoint(0,0) );
          ptr = contours;
          for( i=1; i&lt;ptr-&gt;total; i++)
          {
           p1 = CV_GET_SEQ_ELEM( CvPoint, ptr, i );
  
           p2 = CV_GET_SEQ_ELEM( CvPoint, ptr, i+1 );
  
           x1 = p1-&gt;x;
           y1 = p1-&gt;y;
  
           x2 = p2-&gt;x;
           y2 = p2-&gt;y;
           printf("%d %d     %d %d\n",x1,y1,x2,y2);
           draw_normals(x1,y1,x2,y2);
       }
  }
  </code></pre>
  
  <p>So is there a way to find the length of a contour so that I can divide it by the number of normals I want to draw. Thanks in advance.</p>
  
  <p>EDIT: The draw_normal function draws the normals between two points passed to it as parameters.</p>