title: how to correctly select the outline of the board in opencv?
body: <p>I'm trying to determine the boundaries of the chessboard (they are bounded by a black bar)
  <a href="https://i.stack.imgur.com/2OW5y.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/2OW5y.jpg" alt="enter image description here" /></a></p>
  <p>I do the following</p>
  <pre><code>    img = cv2.imread(filename)
      gray = cv2.cvtColor(img, cv2.COLOR_BGR2HSV)
      cv2.imwrite(&quot;gray.jpg&quot;, gray)
  </code></pre>
  <p><a href="https://i.stack.imgur.com/ywXcf.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ywXcf.jpg" alt="enter image description here" /></a></p>
  <pre><code>    thresh = cv2.inRange(gray, hsv_min, hsv_max)
  
      kernel = cv2.getStructuringElement(cv2.MORPH_RECT, (7, 7))
      thresh = cv2.dilate(thresh, kernel, iterations = 1)
      thresh = cv2.erode(thresh, None, iterations = 4)
  </code></pre>
  <p><a href="https://i.stack.imgur.com/9YNtu.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/9YNtu.jpg" alt="enter image description here" /></a></p>
  <p>and there's no way I can get a better result, after</p>
  <pre><code>contours0, hierarchy = cv2.findContours(thresh.copy(), cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)
      for cnt in contours0:
          rect = cv2.minAreaRect(cnt)
          box = cv2.boxPoints(rect)
          box = np.int0(box) 
          cv2.drawContours(img, [box], -1, (255, 0, 0), 0)
  
      cv2.imshow('contours', img)
  </code></pre>
  <p><a href="https://i.stack.imgur.com/eEY6J.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/eEY6J.jpg" alt="enter image description here" /></a>
  can someone help me?</p>