title: Trying to segment characters and save it in order to image files. But contours are being drawn in a different order?
body: <p>This is the image input.</p>
  
  <p><img src="https://i.stack.imgur.com/bT7Zh.png"></p>
  
  <p>Using python opencv. I did some pre-processing and found contours using </p>
  
  <pre><code>contours,hierarchy = cv2.findContours(thresh,cv2.RETR_LIST,cv2.CHAIN_APPROX_SIMPLE)
  </code></pre>
  
  <p>then i did the following to save each character</p>
  
  <pre><code>img1 = cv2.imread("test26.png")
  nu = 1
  fin = "final"
  for cnt in contours:
      x,y,w,h = cv2.boundingRect(cnt)
      img2 = img1[y:y+h, x:x+w]
      img3 = Image.fromarray(img2)
      filename = fin + str(nu) + ".png"
      nu = nu + 1
      img3.save(filename)
  </code></pre>
  
  <p>But characters are saved in a tree like order. I don't understand the order.</p>
  
  <p>my intention is to get character by character and ocr it in order and save as text.</p>