title: Python CV2: minAreaRect gives different results on the same image when rotated
body: <p>today I stumbled upon a problem that gave me some headaches and I couldn't figure out a solution.</p>
  <p>I want to find the borders of an image with opencv-python / cv2. This is my code:</p>
  <pre><code>(T, thresh) = cv2.threshold(blurredImage, brightnessMin, 255, cv2.THRESH_BINARY_INV)
  contours, hierarchy = cv2.findContours(thresh, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)
  try: hierarchy = hierarchy[0]
  except: hierarchy = []
  thresh = cv2.cvtColor(thresh, cv2.COLOR_GRAY2BGR)
  for contour, hier in zip(contours, hierarchy):
      (x,y,w,h) = cv2.boundingRect(contour)
      rect      = cv2.minAreaRect(contour)
      box       = cv2.boxPoints(rect)
      box       = np.int0(box)
  </code></pre>
  <p>So far nothing special.</p>
  <p>I want to get the same result for rotated images. The borders should be the same either if the image is rotated 90 degrees or 180 degrees.</p>
  <p>But when I rotate my image I get completely different rectangles. Here are two images for comparison:</p>
  <p><a href="https://i.stack.imgur.com/y7bMP.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/y7bMP.jpg" alt="Normal Orientation" /></a></p>
  <p><a href="https://i.stack.imgur.com/blH37.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/blH37.jpg" alt="180 degree rotation" /></a></p>
  <p>The first image is the standard orientation.</p>
  <p>And the second one is 180 degrees rotated (and rotated backwards for comparison).</p>
  <p>I didn't filtered the rectangles.</p>
  <p>I simply don't know why the results are so different. Can somebody maybe help me?</p>
  <p>I use opencv-python 4.1.2.30. I know it's a way older version but newer versions made my whole script unusable because some things have changend and I didn't know what exactly was wrong.</p>
  <p>My Python Version: Python 3.8.0 (tags/v3.8.0:fa919fd, Oct 14 2019, 19:37:50) [MSC v.1916 64 bit (AMD64)] on win32</p>
  <p>Thanks everyone :)</p>