OpenCV(컴퓨터비전)

5. image draw

jasonshin 2021. 12. 27. 17:32
import cv2
import numpy as np

image = cv2.imread('data/images/mark.jpg')

cv2.imshow('img', image)


# 선그리기
imageLine = image.copy()
cv2.line(imageLine, (322, 179), (400, 183), (255, 0, 0), 3, cv2.LINE_AA)

cv2.imshow('image Line', imageLine)

# 원그리기
imaeCircle = image.copy()
cv2.circle(imaeCircle, (350, 200), 150, (255,0,0), cv2.LINE_AA)

cv2.imshow('image circle', imaeCircle)

# 타원그리기
imageEllipse = image.copy()
cv2.ellipse(imageEllipse, (360,200), (100,170), 45, 0, 360, (0, 255, 0), 2)
cv2.ellipse(imageEllipse, (360,200), (100,170), 135, 0, 360, (0,0,255), thickness=2)

cv2.imshow('ellipse', imageEllipse)

# 사각형그리기
imageRectangle = image.copy()
cv2.rectangle(imageRectangle, (208,55), (450,355), (0, 255, 0), 3)

cv2.imshow('rectangle', imageRectangle)

# 글자 넣기
imageText = image.copy()
cv2.putText(imageText, "Mark Zuckerberg", (205,50),
            cv2.FONT_HERSHEY_SIMPLEX, 1, (0,255,0), 2)
cv2.imshow('text', imageText)



cv2.waitKey(0)
cv2.destroyAllWindows()



 
반응형