Hint
🧠 Not sure where to start?
Start by importing the libraries you'll need:
import cv2
import os
Now think: how can you loop through all image files in a folder and draw text on each image?
You’ll want to use a for
loop like this:
for filename in os.listdir("images"):
if filename.endswith(".jpg"):
image = cv2.imread("images/" + filename)
Then use cv2.putText()
to overlay the text:
cv2.putText(image, "Sample Text", (50, 50), cv2.FONT_HERSHEY_SIMPLEX, 1.5, (255, 255, 255), 3)
Finally, save the new image using cv2.imwrite(...)
.