title: Contour Approximation OpenCV
body: <p>I am using <code>OpenCV</code> for <code>python</code>. For a bad shape, we use <code>approxpolyDP()</code>.
  For this, I created a bad rectangle(added to the post), While using this, I only get 2 dots and not a proper rectangle.
  Can anyone help me why this is happening?</p>
  <pre class="lang-py prettyprint-override"><code>import cv2
  import numpy as np
  
  im = cv2.imread(&quot;badrect.png&quot;)
  img = im
  img = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
  canny = cv2.Canny(img,100,200)
  
  
  (_,cnts,_) = cv2.findContours(canny,cv2.RETR_TREE,cv2.CHAIN_APPROX_NONE)
  
  cnt = cnts[0]
  
  epsilon = 0.1*cv2.arcLength(cnt,True)
  approx = cv2.approxPolyDP(cnt,epsilon,True)
  
  cv2.drawContours(im,approx,-1,(0,255,0),3)
  
  cv2.imshow(&quot;img&quot;,im)
  cv2.waitKey(0)
  cv2.destroyAllWindows()
  </code></pre>
  <p>This is how the result looks like</p>
  <p><img src="https://i.stack.imgur.com/skM2L.png" alt="Bad rectangle" /></p>
  <p>This is how I want it to come as</p>
  <p><img src="https://i.stack.imgur.com/mjyzb.jpg" alt="desired output" /></p>
  <p>Thanks in advance! :)</p>