title: I want to sort the words extracted from image in order of their occurence using contours detection
body: <p>I am making an OCR, I am using contours detection, I have extracted words and drawn bounding boxes but the problem is that when I crop the individual word, they are not in sorted order. I have tried sorting methods mentioned in this <a href="https://answers.opencv.org/question/179510/how-can-i-sort-the-contours-from-left-to-right-and-top-to-bottom/" rel="nofollow noreferrer">link</a> to sort the contours but they work best on objects but in my case i want to make the order exact. sometimes the sorting is not the best solution it changes pattern of words as different words have different size of bounding boxes in same line and values of 'x' and 'y' varies with it. Now in same line, words with large bounding boxes are considered as one category and small ones are considered as other category and they get sorted in same fashion.This is the code to sort.  </p>
  
  <pre><code>    sorted_ctrs=sorted(ctrs, key=lambda ctr: cv2.boundingRect(ctr)[0] + cv2.boundingRect(ctr)[1] * 
      im.shape[1] )
  </code></pre>
  
  <p><a href="https://ibb.co/b73dZ46" rel="nofollow noreferrer">image of extracted bounded boxes</a> <br>
  <a href="https://ibb.co/HB1Yn1y" rel="nofollow noreferrer">this is what I get after cropping from sorted contours</a></p>
  
  <p>Is there any other method which can arrange my words so that it makes some sense?</p>