I draw a rectangle on my image using
cv2.rectangle(frame,(x,y),(x1,y1),(0,255,0),2)
I would like to draw rectangles with text information on t
you may need to extend your code with a function that takes your text as input, position_x, position_y .. and it will measure the size of the letters and dynamically set a rectangle width based on that.
you can use: cv2.getTextSize(text, font, font_scale, thickness)
to get how many pixels will it use and then use it to define the rectangle width.