def find_lane_pixels(self, binary_warped, location):
    self.current_warped_binary = binary_warped
    self.current_warped_binary_shape = binary_warped.shape
    self.ploty = np.linspace(0, (binary_warped.shape[0] - 1), binary_warped.shape[0])
    histogram = np.sum(binary_warped[(binary_warped.shape[0] // 2):, :], axis=0)
    midpoint = np.int((histogram.shape[0] // 2))
    if (location == 'left'):
        base = np.argmax(histogram[:midpoint])
    elif (location == 'right'):
        base = (np.argmax(histogram[midpoint:]) + midpoint)
    nwindows = 9
    margin = 80
    minpix = 50
    window_height = np.int((binary_warped.shape[0] // nwindows))
    nonzero = binary_warped.nonzero()
    nonzeroy = np.array(nonzero[0])
    nonzerox = np.array(nonzero[1])
    current = base
    lane_inds = []
    for window in range(nwindows):
        win_y_low = (binary_warped.shape[0] - ((window + 1) * window_height))
        win_y_high = (binary_warped.shape[0] - (window * window_height))
        win_x_low = (current - margin)
        win_x_high = (current + margin)
        good_inds = ((((nonzeroy >= win_y_low) & (nonzeroy < win_y_high)) & (nonzerox >= win_x_low)) & (nonzerox < win_x_high)).nonzero()[0]
        lane_inds.append(good_inds)
        if (len(good_inds) > minpix):
            current = np.int(np.mean(nonzerox[good_inds]))
    try:
        lane_inds = np.concatenate(lane_inds)
    except ValueError:
        pass
    x = nonzerox[lane_inds]
    y = nonzeroy[lane_inds]
    self.allx = x
    self.ally = y
    return (x, y)
def find_lane_pixels(self, binary_warped, location):
    self.current_warped_binary = binary_warped
    self.current_warped_binary_shape = binary_warped.shape
    self.ploty = np.linspace(0, (binary_warped.shape[0] - 1), binary_warped.shape[0])
    histogram = np.sum(binary_warped[(binary_warped.shape[0] // 2):, :], axis=0)
    midpoint = np.int((histogram.shape[0] // 2))
    if (location == 'left'):
        base = np.argmax(histogram[:midpoint])
    elif (location == 'right'):
        base = (np.argmax(histogram[midpoint:]) + midpoint)
    nwindows = 9
    margin = 80
    minpix = 50
    window_height = np.int((binary_warped.shape[0] // nwindows))
    nonzero = binary_warped.nonzero()
    nonzeroy = np.array(nonzero[0])
    nonzerox = np.array(nonzero[1])
    current = base
    lane_inds = []
    for window in range(nwindows):
        win_y_low = (binary_warped.shape[0] - ((window + 1) * window_height))
        win_y_high = (binary_warped.shape[0] - (window * window_height))
        win_x_low = (current - margin)
        win_x_high = (current + margin)
        good_inds = ((((nonzeroy >= win_y_low) & (nonzeroy < win_y_high)) & (nonzerox >= win_x_low)) & (nonzerox < win_x_high)).nonzero()[0]
        lane_inds.append(good_inds)
        if (len(good_inds) > minpix):
            current = np.int(np.mean(nonzerox[good_inds]))
    try:
        lane_inds = np.concatenate(lane_inds)
    except ValueError:
        pass
    x = nonzerox[lane_inds]
    y = nonzeroy[lane_inds]
    self.allx = x
    self.ally = y
    return (x, y)