def draw_lines(img, lines, color=[255, 0, 0], thickness=2):
"""
averaging
&
extrapolating
lines points achieved.
"""
if len(img.shape) == 2: # grayscale image -> make a "color" image out of it
img = np.dstack((img, img, img))
for line in lines:
for x1, y1, x2, y2 in line:
if x1 >= 0 and x1 < img.shape[1] and \
y1 >= 0 and y1 < img.shape[0] and \
x2 >= 0 and x2 < img.shape[1] and \
y2 >= 0 and y2 < img.shape[0]:
cv2.line(img, (x1, y1), (x2, y2), color, thickness)
else:
print('BAD LINE (%d, %d, %d, %d)' % (x1, y1, x2, y2))
main.py 文件源码
python
阅读 20
收藏 0
点赞 0
评论 0
评论列表
文章目录