Created Python version from Draw Arrows 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
#The width of the arrow
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))
#Draw the tip of the arrow
cv2.line(img,pt2,ptl,color,thickness,lineType,shift)
cv2.line(img,pt2,ptr,color,thickness,lineType,shift)
I'm blogging: http://weed.nagoya
Recommended Posts