Pyqt - opencv with Qlabel widget

I need some help for getting the right way on using pyqt and opencv. I would like to make a desktop aplication for annotate annomalies in medical images; basically to Qlabel widgets: the left one for explore the image files and the right one for getting a ROI of the region where the annomalie is, so when this region be display in the Qlabel of the right part you can define its edges…so my questions are:

  1. can this be done through QImage and QPixmap (I’ve used mouspressevent for getting the rectangle coordinates, the global ones and the ones related with the widget but are not related with the original images), also I’m new using this plattforms really get lost with this representation, I have a 10% of experience using matlab and the representation I have is matrixial, so the real question can you slice or subimages QImage…
  2. I’m scaling the image in the QImage for passing it to the Qlabel widget, do I need to use the rect funtion for getting a scale rate so that mouse click correspond to the Qlabel visualize area…
  3. Its necessary to used this combination opencv → qimage → qpixmap all the way for using opencv and Qt advantages…
    thanks a lot for your time and for the knowhow…greetings
  1. You can use QLabel to display QPixmaps. However, you need to be able to transform the coordinates in the QLabel to coordinates for the QPixmap. This will depend on the alignment of the image and the margins of the label. It’s probably easier to create a small QWidget subclass and reimplement the paintEvent to draw the pixmap so that you know exactly where it is within the widget.
    See the OwnImageWidget class from this example for ideas about how to do this.
  2. You need to record the scale factor for the QImage somewhere so that you can transform the coordinates of the pixmap back to coordinates of the original image. The rect() method might help with this, but you would have to explain how you intend to use it.
  3. Perhaps there is a custom widget that allows data from OpenCV to be displayed directly in a Qt widget. The OpenCV/PyQt examples I have seen all seem to perform conversions to QImage at least. If you create a custom widget to draw a QImage then you don’t need to use QPixmap at all.

Thanks David for your time, I’ll follow the example and will try to find the way, I 've already trying to find a scale rate using the Qlabel.size respect to QImage.size, but it is not constant (I get some value when only left Qlabel is showing the image and then when I load the ‘asyncronous’ ROI it gets another size value), so I’ll try with your advice using rect(). thanks again for sharing…the problem (for me) I think it’s related to the layers in between from an image file to a QPixmap…and I haven’t got yet a real idea of this layers representation, thinking about matrices. thanks again, I keep trying.