I'm having trouble with import cv
in my python code.
My issue is I need to draw a rectangle around regions of interest in an image. How can this be done in python? I'm doing object detection and would like to draw a rectangle around the objects I believe I've found in the image.
You can use
cv2.rectangle()
:I have a PIL Image object and I want to draw rectangle on this image, but PIL's ImageDraw.rectangle() method does not have the ability to specify line width. I need to convert Image object to opencv2's image format and draw rectangle and convert back to Image object. Here is how I do it:
please don't try with the old cv module, use cv2:
[edit] to append the follow-up questions below: