我收到此错误,无法理解为什么会出现此问题。下面是代码和错误。
上次可打印锻炼的结果
[-8.54582258e-01 9.83741381e+02] left
[ 0.776281243 -160.77584028] right
Run Code Online (Sandbox Code Playgroud)
代码错误发生在make_coordinates,该行是
slope, intercept = line_parameters
Run Code Online (Sandbox Code Playgroud)
这是完整的代码:
import cv2
import numpy as np
vid = cv2.VideoCapture('carDriving.mp4')
def processImage(image):
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
blur = cv2.GaussianBlur(gray, (5,5), 0)
canny = cv2.Canny(blur, 50, 150)
return canny
def region_of_interest(image):
height = image.shape[0]
polygons = np.array([
[(200,height), (1200,height), (750,300)]
])
mask = np.zeros_like(image)
cv2.fillPoly(mask, polygons, 255)
masked_image = cv2.bitwise_and(image, mask)
return masked_image
def display_lines(image, lines):
line_image = np.zeros_like(image)
if lines is not None:
for …Run Code Online (Sandbox Code Playgroud)