使用 putText() 函式在 OpenCV 視窗顯示文字
在本教程中,我們將使用 opencv 函式 putText() 在影像上書寫文字。此函式帶入影像、字型、文字位置座標、顏色、粗細等。
原始影像
演算法
Step 1: Import cv2 Step 2: Define the parameters for the puttext( ) function. Step 3: Pass the parameters in to the puttext() function. Step 4: Display the image.
程式碼示例
import cv2 image = cv2.imread("testimage.jpg") text = "TutorialsPoint" coordinates = (100,100) font = cv2.FONT_HERSHEY_SIMPLEX fontScale = 1 color = (255,0,255) thickness = 2 image = cv2.putText(image, text, coordinates, font, fontScale, color, thickness, cv2.LINE_AA) cv2.imshow("Text", image)
輸出
廣告