title: How to have contours first coordinate always be on the top left?
body: <p>Ok, so my contours are always rectangles or squares so I have only 4 coordinates for each one ([top_left, bottom_left, bottom_right, top_right]). But for some contours the first coordinate isn't the one on the top_left, it could start from any of 4 corners.
  How can I make them always start at one corner every time?</p>
  
  <p>Here are pictures where numbers represent the order of coordinates:
  <a href="https://i.imgur.com/bPt7Wah.png" rel="nofollow noreferrer">https://i.imgur.com/bPt7Wah.png</a></p>
  
  <p>I use these coordinates to crop the image but if the coordinates are not in the right order it doesn't work.
  Here is the code for cropping:</p>
  
  <pre><code>def get_colors(img, squares):
      for square in squares:
          x0, y0 = square[0]
          x1, y1 = square[1]
          x2, y2 = square[2]
          x3, y3 = square[3]
  
          top_left_x = max([x0, x1])
          top_left_y = max([y0, y3])
          bot_right_x = min([x2, x3])
          bot_right_y = min([y1, y2])
  
          croped = img[top_left_y:bot_right_y, top_left_x:bot_right_x]
  </code></pre>