import matplotlib.pyplot as plt
import matplotlib.image as mpimg
import numpy as np
import cv2
import math
import os
import json
image = cv2.imread('/home/dell/lane1.jpg')
image = cv2.cvtColor(image,cv2.COLOR_RGB2GRAY)
image = cv2.GaussianBlur(image,(3,3),0)
img = cv2.Canny(image, 10, 80)
#mask
mask = np.zeros_like(img)
if len(img.shape)>2:
channel = img.shape[2]
ignore_mask_color = (255,) * channel_count
else:
ignore_mask_color = 255
print(img.shape[0])
vertices = np.array([[(0,img.shape[0]),(100,img.shape[0]*0.8),(250,img.shape[0]*0.8),(img.shape[1],img.shape[0]),(0,img.shape[0])]])
cv2.fillPoly(mask, vertices, ignore_mask_color)
masked_image = cv2.bitwise_and(img, mask) # 与操作
#line
lines=cv2.HoughLinesP(masked_image,rho=2, theta=np.pi / 180, threshold=100, min_line_len=10, max_line_gap=10)
hline_show = {'hlines': 'on', 'avg': 'on', 'steps': 'on'}
if hline_show['steps']=='on':
#
#cv2.imshow('image',image)
#cv2.waitKey(0)
self-lane
最新推荐文章于 2021-06-19 14:04:32 发布