def drawArrow(image, p, q, color, arrowMagnitude = 5, thickness=1, line_type=8, shift=0):
# Draw the principle line
cv2.line(image, tuple(p), tuple(q), color, thickness, line_type, shift);
# compute the angle alpha
angle = numpy.arctan2( p[1]-q[1], p[0]-q[0]);
# compute the coordinates of the first segment
p[0] = int(q[0] + arrowMagnitude * numpy.cos(angle + numpy.pi/4.0));
p[1] = int(q[1] + arrowMagnitude * numpy.sin(angle + numpy.pi/4.0));
# /Draw the first segment
cv2.line(image, tuple(p), tuple(q), color, thickness, line_type, shift);
# compute the coordinates of the second segment
p[0] = int(q[0] + arrowMagnitude * numpy.cos(angle - numpy.pi/4.0));
p[1] = int(q[1] + arrowMagnitude * numpy.sin(angle - numpy.pi/4.0));
# Draw the second segment
cv2.line(image, tuple(p), tuple(q), color, thickness, line_type, shift);
# cv2.putText(image, str(int(180.0*angle/numpy.pi)), tuple(p), cv2.FONT_HERSHEY_COMPLEX_SMALL, 1, 255 )
return image
visualMovieAnalysis2.py 文件源码
python
阅读 32
收藏 0
点赞 0
评论 0
评论列表
文章目录