I am using the following code to detect face and draw rectangle on top of the face.
while True:
# get video frame
ret, img = cap.read()
input_img =
I did something naive. You can implement with further modifications using a function.
I manually marked a rectangle around the text and extracted the 4 points.
Then I fixed a length for the line to be drawn from these 4 points.
Result:
Functions used:
cv2.line()
cv2.rectangle()
See THIS LINK for details about their usage.