Loading train1/ld_module_binary.py +7 −0 Changes for train1/ld_module_binary.py: 7 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -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)): Loading Loading @@ -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') Loading @@ -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 Loading @@ -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 Loading @@ -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 Loading Loading @@ -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 train1/main.py +4 −5 Changes for train1/main.py: 4 added lines, 5 removed lines. Original line number Diff line number Diff line Loading @@ -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) Loading Loading @@ -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): Loading @@ -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 + Loading @@ -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)) Loading
train1/ld_module_binary.py +7 −0 Changes for train1/ld_module_binary.py: 7 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -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)): Loading Loading @@ -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') Loading @@ -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 Loading @@ -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 Loading @@ -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 Loading Loading @@ -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
train1/main.py +4 −5 Changes for train1/main.py: 4 added lines, 5 removed lines. Original line number Diff line number Diff line Loading @@ -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) Loading Loading @@ -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): Loading @@ -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 + Loading @@ -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))