def process_an_image(img):
roi_vtx = np.array([[(0, img.shape[0]), (460, 325), (520, 325), (img.shape[1], img.shape[0])]])
gray = cv2.cvtColor(img, cv2.COLOR_RGB2GRAY)
blur_gray = cv2.GaussianBlur(gray, (blur_ksize, blur_ksize), 0, 0)
edges = cv2.Canny(blur_gray, canny_lthreshold, canny_hthreshold)
roi_edges = roi_mask(edges, roi_vtx)
line_img = hough_lines(roi_edges, rho, theta, threshold, min_line_length, max_line_gap)
res_img = cv2.addWeighted(img, 0.8, line_img, 1, 0)
# plt.figure()
# plt.imshow(gray, cmap='gray')
# plt.savefig('../resources/gray.png', bbox_inches='tight')
# plt.figure()
# plt.imshow(blur_gray, cmap='gray')
# plt.savefig('../resources/blur_gray.png', bbox_inches='tight')
# plt.figure()
# plt.imshow(edges, cmap='gray')
# plt.savefig('../resources/edges.png', bbox_inches='tight')
# plt.figure()
# plt.imshow(roi_edges, cmap='gray')
# plt.savefig('../resources/roi_edges.png', bbox_inches='tight')
# plt.figure()
# plt.imshow(line_img, cmap='gray')
# plt.savefig('../resources/line_img.png', bbox_inches='tight')
# plt.figure()
# plt.imshow(res_img)
# plt.savefig('../resources/res_img.png', bbox_inches='tight')
# plt.show()
return res_img
# img = mplimg.imread("../resources/lane.jpg")
# process_an_image(img)
评论列表
文章目录