Création de la version Python à partir de Draw arrow with OpenCV.
def cvArrow(img, pt1, pt2, color, thickness=1, lineType=8, shift=0):
cv2.line(img,pt1,pt2,color,thickness,lineType,shift)
vx = pt2[0] - pt1[0]
vy = pt2[1] - pt1[1]
v = math.sqrt(vx ** 2 + vy ** 2)
ux = vx / v
uy = vy / v
#La largeur de la flèche
w = 5
h = 10
ptl = (int(pt2[0] - uy*w - ux*h), int(pt2[1] + ux*w - uy*h))
ptr = (int(pt2[0] + uy*w - ux*h), int(pt2[1] - ux*w - uy*h))
#Dessinez la pointe de la flèche
cv2.line(img,pt2,ptl,color,thickness,lineType,shift)
cv2.line(img,pt2,ptr,color,thickness,lineType,shift)
Je blogue: http://weed.nagoya
Recommended Posts