title: Finding the corners of a rectangle
body: <p>I'm trying to get the corners of this rectangle:</p>
  
  <p><img src="https://i.stack.imgur.com/6dUIr.png" alt="this rectangle">.</p>
  
  <p>I tried using <code>cv2.cornerHarris(rectangle, 2, 3, 0.04)</code>, but the left edges are not showed due to image brightness, I guess. So I tried applying a threshold before using cornerHarris, but the image produced showed a lot of vertices along the edges, not being possible to filter the corners.</p>
  
  <p>I know that I need to filter it before using cornerHarris, but I don't know how. Could someone help me with this problem?</p>
  
  <p>Ps. I've already tried to use blur, but it also doesn't work.</p>
  
  <pre><code>import cv2
  import numpy as np
  import matplotlib.pyplot as plt
  
  rectangle = cv2.imread('rectangle.png', cv2.IMREAD_GRAYSCALE)
  rectangle = np.where(rectangle &gt; np.mean(rectangle), 255, 0).astype(np.uint8)
  
  dst_rectangle = cv2.cornerHarris(rectangle, 2, 3, 0.04)
  dst_rectangle = cv2.dilate(dst_rectangle, None)
  
  mask = np.where(dst_rectangle &gt; 0.01*np.max(dst_rectangle), 255, 0).astype(np.uint8)
  points = np.nonzero(mask)
  
  plt.imshow(dst_rectangle, cmap='gray')
  plt.plot(points[1], points[0], 'or')
  plt.show()
  </code></pre>