opencv rectangle painted in the image, add txt, and save:
import cv2
fname = '/path/xxx.jpg'
img = cv2.imread(fname)
cv2.rectangle(img, (10,50), (50,100), (0,255,0), 4)
font = cv2.FONT_HERSHEY_SIMPLEX
text = '001'
cv2.putText(img, text, (50, 50), font, 1, (0,0,255), 1)
cv2.imwrite('/path/001_new.jpg', img)
Function Description:
(1) cv2.rectangle (img, the upper left corner, lower right corner, Color, width)
(2) cv2.putText (img, text, starting coordinates, fonts, font, font size, color, font weight)
The results show: