python opencv putText

发布时间 2023-04-11 19:38:06作者: 西北逍遥

python opencv putText

 

import cv2

# Load image
img = cv2.imread("image.jpg")

# Define text to draw
text = "Hello, World!"

# Define position to draw text at
position = (50, 50)

# Define font type, scale, color, and thickness
font = cv2.FONT_HERSHEY_SIMPLEX
font_scale = 1
color = (0, 0, 255)
thickness = 2

# Draw text on image
cv2.putText(img, text, position, font, font_scale, color, thickness)

# Display image
cv2.imshow("Image with Text", img)
cv2.waitKey(0)
cv2.destroyAllWindows()

  

 

###################