Skip to content

Instantly share code, notes, and snippets.

@IanMcT
Created January 16, 2017 19:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save IanMcT/1a6537458f9847e388b7f4e053544bbf to your computer and use it in GitHub Desktop.
Save IanMcT/1a6537458f9847e388b7f4e053544bbf to your computer and use it in GitHub Desktop.
How to write on an image
import numpy as np
import cv2
# Create a black image
#img = np.zeros((512,512,3), np.uint8)
img = cv2.imread('images/test_image.png')
# Write some Text
font = cv2.FONT_HERSHEY_SIMPLEX
cv2.putText(img,'Hello World!',(10,200), font, 1,(255,255,255),2)
#Display the image
cv2.imshow("img",img)
#Save image
cv2.imwrite("out.jpg", img)
cv2.waitKey(0)
#
#
#
# font = cv2.FONT_HERSHEY_SIMPLEX
# cv2.putText(img,'Hello World!',(10,500), font, 1,(255,255,255),2)
cv2.imwrite('images/writtenon.png',img)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment