Commit e7c97bed authored by Sparkf's avatar Sparkf 🏙️
Browse files

comment code for plotting image

parent 4c8384fa
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -2,6 +2,7 @@ import numpy as np
import cv2
import ld_module_transform
from numba import njit, prange
import matplotlib.pyplot as plt

def get_bin_img(img, kernel_size=3, sobel_dirn='X', sobel_thresh=(0, 255), r_thresh=(0, 255),
                s_thresh=(0, 255), b_thresh=(0, 255), g_thresh=(0, 255)):
@@ -29,6 +30,7 @@ def get_bin_img(img, kernel_size=3, sobel_dirn='X', sobel_thresh=(0, 255), r_thr
    # Threshold R color channel
    r_binary = get_rgb_thresh_img(img, thresh=r_thresh)


    # Threshhold G color channel
    g_binary = get_rgb_thresh_img(img, thresh=g_thresh, channel='G')

@@ -38,10 +40,12 @@ def get_bin_img(img, kernel_size=3, sobel_dirn='X', sobel_thresh=(0, 255), r_thr
    # Threshold color channel
    s_binary = get_hls_sthresh_img(img, thresh=s_thresh)


    # If two of the three are activated, activate in the binary image
    combined_binary = np.zeros_like(combined)
    combined_binary[(r_binary == 1) | (combined == 1) | (s_binary == 1) | (b_binary == 1) | (g_binary == 1)] = 1


    return combined_binary


@@ -52,6 +56,7 @@ def get_hls_sthresh_img(img, thresh=(0, 255)):
    binary_output = np.zeros_like(S).astype(np.uint8)
    binary_output[(S >= thresh[0]) & (S < thresh[1])] = 1


    return binary_output


@@ -62,6 +67,7 @@ def get_lab_bthresh_img(img, thresh=(0, 255)):
    bin_op = np.zeros_like(B).astype(np.uint8)
    bin_op[(B >= thresh[0]) & (B < thresh[1])] = 1


    return bin_op


@@ -102,4 +108,5 @@ def abs_thresh(img, sobel_kernel=9, mag_thresh=(0, 255), return_grad=False, dire
    grad_binary = np.zeros_like(scaled_sobel)
    grad_binary[(scaled_sobel >= mag_thresh[0]) & (scaled_sobel < mag_thresh[1])] = 1


    return grad_binary
+4 −5
Original line number Diff line number Diff line
@@ -91,7 +91,7 @@ def lane_detection(input_img, original_img, i):
    # plt.subplot(121)

    # 3.1.3 find lane via sliding window
    plt.imshow(input_img)
    # plt.imshow(input_img)
    mark_layer = np.zeros((600, 600, 3), np.uint8)
    for midpoint in img_peak_histogram:
        # midpoint (width)
@@ -134,8 +134,8 @@ def lane_detection(input_img, original_img, i):
    # simulate not save image
    cv2.imwrite("op_module/" + foldername + "_" + filename + ".png", original_img)

    plt.imshow(cv2.cvtColor(original_img.astype("uint8"), cv2.COLOR_BGR2RGB))
    plt.savefig("output.svg", format='svg', dpi=600)
    # plt.imshow(cv2.cvtColor(original_img.astype("uint8"), cv2.COLOR_BGR2RGB))
    # plt.savefig("output.svg", format='svg', dpi=600)


for subdir, dirs, files in os.walk(rootdir):
@@ -159,7 +159,7 @@ for subdir, dirs, files in os.walk(rootdir):
            input_img = cv2.cvtColor(input_img, cv2.COLOR_BGR2RGB)

            # yellow filter
            input_img = cv2.cvtColor(input_img, cv2.COLOR_BGR2RGB)
            # input_img = cv2.cvtColor(input_img, cv2.COLOR_BGR2RGB)
            original_img = input_img
            # img_buffer_array[rotate_num] = input_img
            # input_img = (img_buffer_array[(rotate_num) % 4] * 0.25 + img_buffer_array[(rotate_num - 1) % 4] * 0.25 +
@@ -177,4 +177,3 @@ for subdir, dirs, files in os.walk(rootdir):

            lane_detection(input_img, original_img, k2)
print("--- %s seconds ---" % (time.time() - start_time))