title: Find corner of papers
body: <p>I am new in openCV so struggling from last 3 to 4 days, I already detect paper sheet boundary, Now I wants to draw 4 circles on the corners.</p>
  
  <p>I draw boundary from this code</p>
  
  <pre><code>const cv::Point* p = &amp;squares[i][0];
  
  int n = (int)squares[i].size();
  
  polylines(image, &amp;p,&amp;n, 1, true, Scalar(255,255,0), 5, CV_AA);
  </code></pre>
  
  <p>I am new in openCV, So In my opinion I have upper left corner points p->x  and p->y, But how I get the others corners, I am also confused in parameter &amp;n in this polylines method, how this polylines method draw complete rectangle?</p>
  
  <p>When I use bounding rect, It's not perfect it give's little space on side of paper sheet.</p>
  
  <p>Any help is really appreciated</p>
  
  <p>code is :</p>
  
  <pre><code>- (cv::Mat)finshWork:(cv::Mat &amp;)image
  {
  // read in the apple (change path to the file)
  Mat img0 =image;// imread("/home/philipp/img/apple.jpg", 1);
  
  Mat img1;
  cvtColor(img0, img1, CV_RGB2GRAY);
  
  // apply your filter
  Canny(img1, img1, 100, 200);
  
  // find the contours
  vector&lt; vector&lt;cv::Point&gt; &gt; contours;
  findContours(img1, contours, CV_RETR_EXTERNAL, CV_CHAIN_APPROX_NONE);
  
  /////for SQUARE CODE
  std::vector&lt;std::vector&lt;cv::Point&gt; &gt; squares;
  std::vector&lt;cv::Point&gt; approx;
  for( size_t i = 0; i &lt; contours.size(); i++ )
  {
      cv::approxPolyDP(cv::Mat(contours[i]), approx, arcLength(cv::Mat(contours[i]), true)*0.02, true);
      if( approx.size() == 4 &amp;&amp; fabs(contourArea(cv::Mat(approx))) &gt; 1000 &amp;&amp; cv::isContourConvex(cv::Mat(approx))) {
          double maxCosine = 0;
  
          for( int j = 2; j &lt; 5; j++ )
          {
              double cosine = fabs(angle(approx[j%4], approx[j-2], approx[j-1]));
              maxCosine = MAX(maxCosine, cosine);
          }
  
          if( maxCosine &lt; 0.3 ) {
              squares.push_back(approx);
              cv::Point newPoint = approx[0]; 
  
              NSLog(@"x is %d and  y is %d",newPoint.x,newPoint.y);
          }
      }
  }
  
  const cv::Point* p = &amp;squares[0][0];
  
  
  int n = (int)squares[0].size();
  
  NSLog(@"%d",n);
  
  
  //THIS IS WORKING CODE              
  
      polylines(image, &amp;p,&amp;n, 1, true, Scalar(0,0,255), 10, CV_AA);
      //polylines(image, &amp;p,&amp;n, 1, true, Scalar(255,255,0), 5, CV_AA);
  ////////////
  }
  </code></pre>
  
  <p>Thanks</p>