def perspective_transform(image, corners, debug=False, xoffset=0):
height, width = image.shape[0:2]
output_size = height/2
new_top_left=np.array([corners[0,0],0])
new_top_right=np.array([corners[3,0],0])
offset=[xoffset,0]
img_size = (image.shape[1], image.shape[0])
src = np.float32([corners[0],corners[1],corners[2],corners[3]])
dst = np.float32([corners[0]+offset,new_top_left+offset,new_top_right-offset ,corners[3]-offset])
M = cv2.getPerspectiveTransform(src, dst)
warped = cv2.warpPerspective(image, M, (width, height), flags=cv2.INTER_LINEAR)
if debug:
drawQuad(image, src, [255, 0, 0])
drawQuad(warped, dst, [255, 255, 0])
plt.imshow(image)
plt.show()
plt.imshow(warped)
plt.show()
return warped, src, dst
lane_detection_module.py 文件源码
python
阅读 27
收藏 0
点赞 0
评论 0
评论列表
文章目录