title: How to crop multiple ROI in image using Python and OpenCV
body: <p>I have an image that converted from PDF to PNG. The converted image contains several keywords that I wanted to extracted using OCR Tesseract.</p>
  <p>Right now, I need to determine the ROI manually to crop the selected ROI. Since I have more than 5 ROI's to be applied, what would be the most efficient way to apply the ROI instead of doing it by try and error to find the exact location?</p>
  <p><a href="https://i.stack.imgur.com/Gc3Qc.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Gc3Qc.jpg" alt="enter image description here" /></a></p>
  <p>Below is the code:</p>
  <pre><code>    def cropped(self, event):
  
          #1st ROI
          y = 20
          x = 405
          h = 230
          w = 425
  
          #2nd ROI
          y1 = 30
          x1 = 305
          h1 = 330
          w1 = 525
  
          #open the converted image
          image = cv2.imread(&quot;Output.png&quot;)
  
          #perform image cropping
          crop_image = image[x:w, y:h]
          crop_image1 = image[x1:w1, y1:h1]
          
          #save the cropped image
          cv2.imwrite(&quot;Cropped.png&quot;, crop_image)
          cv2.imwrite(&quot;Cropped1.png&quot;, crop_image1)
          
          #open the cropped image and pass to the OCR engine
          im = cv2.imread(&quot;Cropped.png&quot;)
          im1 = cv2.imread(&quot;Cropped1.png&quot;)
  
          ## Do the text extraction here
  </code></pre>