核心函数
drawMarker(img, position, color, markerType=None, markerSize=None, thickness=None, line_type=None)
img 需要绘制标记的图像 position 绘制的位置 color 段的颜色 markerType 要使用的标记的特定类型 thickness 线段的线宽 line_type 绘制线的类型 markerSize 标记轴的长度[默认值=20像素]
代码展示
# -*- coding:utf-8 -*-
import cv2
import numpy as np
mark_type_list = [cv2.MARKER_CROSS,
cv2.MARKER_TILTED_CROSS,
cv2.MARKER_STAR,
cv2.MARKER_DIAMOND,
cv2.MARKER_SQUARE,
cv2.MARKER_TRIANGLE_UP,
cv2.MARKER_TRIANGLE_DOWN]
image = np.zeros((480, 640, 3), dtype=np.uint8)
for idx, mark_type in enumerate(mark_type_list):
cv2.drawMarker(image,
position=(50 + 30 * idx, 100),
color=(255, 255, 0),
thickness=2,
markerType=mark_type,
line_type=cv2.LINE_8,
markerSize=20)
cv2.imshow('image', image)
cv2.waitKey()