python opencv putText
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()
###################
QQ 3087438119

浙公网安备 33010602011771号