def test_search_lanes():
    # img_path = '../test_output_folder/bin_img.jpg'
    img_path = '../test_images/straight_lines1.jpg'
    img = cv2.imread(img_path)
    preprocessor = Preprocessor()
    pimg = preprocessor.preprocess_image(img)
    bimg, _ = color_n_edge_threshold(pimg)
    lanedetector = LaneDetector()

    # search_lanes(img,self.is_first_pass=False,l=l,r=r);

    # plt.subplot(121);
    # plt.title("Original Image")
    # plt.imshow(img[:,:,::-1]);

    # # preprocessed_img = preprocess_image(img);
    # plt.subplot(122);
    plt.title("Visulized Image")
    plt.imshow(bimg, cmap='gray')

    l, r, vis_img = lanedetector.search_lanes(bimg, is_first_pass=True)
예제 #2
0
import matplotlib.pyplot as plt
import numpy as np
from slidingwindowsearch import LaneDetector

if __name__ == '__main__':
    test_output_folder = '../test_output_folder/'
    test_folder = '../test_images/'
    if not os.path.exists(test_folder):
        raise Exception("Test Folder does not exists")
    preprocessor = Preprocessor()
    lanedetector = LaneDetector()
    for file_name in os.listdir(test_folder):
        img = cv2.imread(os.path.join(test_folder, file_name))
        #img = img[...,::-1]; # Converting from BGR to RGB

        pre_image = preprocessor.preprocess_image(img)

        #cv2.imwrite(test_output_folder+'3.jpg',cv2.cvtColor(pre_image,cv2.COLOR_RGB2BGR));

        thresh_binary_img, color_binary = color_n_edge_threshold(pre_image)
        left_lane_fit, right_lane_fit, vis_img = lanedetector.search_lanes(
            thresh_binary_img)
        img_h = img.shape[0]
        ploty = np.linspace(start=0, stop=img_h, num=img_h)
        left_fitx = left_lane_fit[0] * ploty**2 + left_lane_fit[
            1] * ploty + left_lane_fit[2]
        right_fitx = right_lane_fit[0] * ploty**2 + right_lane_fit[
            1] * ploty + right_lane_fit[2]
        #thresh_binary_img = preprocessor.inv_perspective_transform(thresh_binary_img);
        overlay = np.uint8(
            np.dstack((thresh_binary_img, np.zeros_like(thresh_binary_img),