title: Python select ROI OpenCV
body: <p><a href="https://i.stack.imgur.com/1yEqA.jpg" rel="nofollow noreferrer">Sample Image</a></p>
  
  <p>Hello,</p>
  
  <p>I created an application in python that select the Region of Interest(ROI) of an image, record and label it. But I has a limit of one ROI per image, anyone know how to have multiple selection of ROI per image? Also on attached image, as you can see I have multiple window, I want it to be in one window with different options, what packages are use on this kind of application.</p>
  
  <p>here's my code in python using opencv2. Thank you in advance for the help</p>
  
  <pre><code>  for image in filelist:
      img = cv2.imread(image)
      fromCenter = False
      r = cv2.selectROI(img, fromCenter)
  
      lbl = simpledialog.askstring("Image Label", "Please Enter Label")
  
      result = eTree.SubElement(results, "Image")
  
      path = eTree.SubElement(result, 'Path')
      roi = eTree.SubElement(result, 'ROI')
      label = eTree.SubElement(result, 'Label')
  
      path.text = str(image)
      roi.text = str(r)
      label.text = str(lbl)
  
      tree = eTree.ElementTree(results)
      i = i + 1
      if i == count:
          format = [('XML Files', '*.xml'), ('All Files', '*.*')]
          save = filedialog.asksaveasfilename(filetype=format, defaultextension='*.xml')
          tree.write(save, xml_declaration=True, encoding='utf-8', method="xml")
  </code></pre>