使用 OpenCV 函式 circle() 繪製一個圓


在本文中,我們將使用 OpenCV 函式 circle() 在影像上繪製一個圓形。

原影像

演算法

Step 1: Import OpenCV.
Step 2: Define the radius of circle.
Step 3: Define the center coordinates of the circle.
Step 4: Define the color of the circle.
Step 5: Define the thickness.
Step 6: Pass the above arguments into cv2.circle() along with the image.
Step 7: Display the output.

示例程式碼

import cv2
image = cv2.imread('testimage.jpg')
radius = 100
center = (350, 175)
color = (255,255,0)
thickness = 15
image = cv2.circle(image, center, radius, color, thickness)
cv2.imshow('Circle', image)

輸出

更新於: 17-Mar-2021

936 次瀏覽

開啟您的 職業生涯

完成課程並獲得認證

開始學習
廣告