函数原型:
cv2.line(img, pt1, pt2, color[, thickness[, lineType[, shift]]])
实例:
cv2.line(img,(0,0),(500,500),(255,0,0),2)
cv2.imshow('画直线', img)
函数原型:
cv2.rectangle(img, pt1, pt2, color[, thickness[, lineType[, shift]]])
实例:
cv2.rectangle(img,(100,50),(200,150),(0,255,0),3)
cv2.imshow('画矩形', img)
函数原型:
cv2.circle(img, center, radius, color[, thickness[, lineType[, shift]]])
实例:
cv2.circle(img, (200,200), 50, (0,0,255), -1)
cv2.imshow('画圆', img)
函数原型:
cv2.ellipse(img, center, axes, angle, startAngle, endAngle, color[, thickness[, lineType[, shift]]])
实例:
cv2.ellipse(img, (256,256), (100,50), 0, 0, 180, 255, -1)
cv2.imshow('画椭圆', img)
函数原型:
cv2.polylines(img, pts, isClosed, color[, thickness[, lineType[, shift]]])
实例:
pts = np.array([[10,5],[20,30],[70,20],[50,10]], np.int32)
pts = pts.reshape((-1,1,2))
cv2.polylines(img,[pts],True,(0,255,255))
cv2.imshow('画多边形', img)
函数原型:
cv2.putText(img, text, org, fontFace, fontScale, color[, thickness[, lineType[, bottomLeftOrigin]]])
实例:
font = cv2.FONT_HERSHEY_SIMPLEX
cv2.putText(img,'OpenCV',(10,500), font, 4,(255,255,255),2,cv.LINE_AA)
cv2.imshow('画文字', img)