728x90
반응형
#cv2.line(image, start, end, color, thickness): 하나의 직선을 그리는 함수
#start: 시작 좌표 (2차원)
#end: 종료 좌표 (2차원)
#thickness: 선의 두께
import cv2
import numpy as np
import matplotlib.pyplot as plt
image = np.full((512, 512, 3), 255, np.uint8)
image = cv2.line(image, (0, 0), (255, 255), (255, 0, 0), 5)
plt.imshow(image)
plt.show()

#cv2.rectangle(image, start, end, color, thickness): 하나의 사각형을 그리는 함수
#start: 시작 좌표 (2차원)
#end: 종료 좌표 (2차원)
#thickness: 선의 두께 (채우기: -1)
import cv2
import numpy as np
import matplotlib.pyplot as plt
image = np.full((512, 512, 3), 255, np.uint8)
image = cv2.rectangle(image, (20, 20), (255, 255), (255, 0, 0), 3)
plt.imshow(image)
plt.show()

#cv2.circle(image, center, radian, color, thickness): 하나의 원을 그리는 함수
#center: 원의 중심 (2차원)
#radian: 반지름
#thickness: 선의 두께 (채우기: -1)
import cv2
import numpy as np
import matplotlib.pyplot as plt
image = np.full((512, 512, 3), 255, np.uint8)
image = cv2.circle(image, (255, 255), 100, (255, 0, 0), 3)
plt.imshow(image)
plt.show()

#cv2.polylines(image, points, is_closed, color, thickness): 하나의 다각형을 그리는 함수
#points: 꼭지점들
#is_closed: 닫힌 도형 여부
#thickness: 선의 두께 (채우기: -1)
import cv2
import numpy as np
import matplotlib.pyplot as plt
image = np.full((512, 512, 3), 255, np.uint8)
points = np.array([[5, 5], [128, 258],[123,123], [483, 444], [400, 150]])
image = cv2.polylines(image, [points], True, (0, 0, 255), 4)
plt.imshow(image)
plt.show()

#cv2.putText(image, text, position, font_type, font_scale, color): 하나의 텍스트를 그리는 함수
#position: 텍스트가 출력될 위치
#font_type: 글씨체
#font_scale: 글씨 크기 가중치
import numpy as np
import matplotlib.pyplot as plt
image = np.full((512, 512, 3), 255, np.uint8)
image = cv2.putText(image, 'Hello Python', (60, 300), cv2.FONT_ITALIC, 2, (255, 0, 0))
plt.imshow(image)
plt.show()

728x90
반응형
'Data Analysis > Data Analysis & Image Processing' 카테고리의 다른 글
11. OpenCV Contours 처리 (0) | 2022.04.16 |
---|---|
10. OpenCV Contours (0) | 2022.04.16 |
8. OpenCV Tracker (0) | 2022.04.16 |
7. OpenCV 임계점 처리하기 (0) | 2022.04.07 |
6. OpenCV 이미지 연산 (0) | 2022.04.07 |
댓글