def process_image(image):
# printing out some stats and plotting
print('This image is:', type(image), 'with dimesions:', image.shape)
gray = grayscale(image)
# Define a kernel size and apply Gaussian smoothing
kernel_size = 5
blur_gray = gaussian_blur(gray, kernel_size)
# plt.imshow(blur_gray, cmap='gray')
# Define our parameters for Canny and apply
low_threshold = 45 #50
high_threshold = 150 #150
edges = canny(blur_gray, low_threshold, high_threshold)
# This time we are defining a four sided polygon to mask
imshape = image.shape
#vertices = np.array([[(0,imshape[0]),(475, 310), (475, 310), (imshape[1],imshape[0])]], dtype=np.int32)
vertices = np.array([[(0,imshape[0]),(450, 330), (490, 310), (imshape[1],imshape[0])]], dtype=np.int32)
masked_edges = region_of_interest(edges, vertices)
# Define the Hough transform parameters
# Make a blank the same size as our image to draw on
rho = 1 # distance resolution in pixels of the Hough grid
theta = np.pi/180 # angular resolution in radians of the Hough grid
threshold = 15 # minimum number of votes (intersections in Hough grid cell)
min_line_length = 40 #minimum number of pixels making up a line 150 - 40
max_line_gap = 130 # maximum gap in pixels between connectable line segments 58 -95
line_image = np.copy(image)*0 # creating a blank to draw lines on
lines = hough_lines(masked_edges, rho, theta, threshold, min_line_length, max_line_gap)
# Draw the lines on the edge image
lines_edges = weighted_img(lines, image)
return lines_edges
评论列表
文章目录