M = cv2.getPerspectiveTransform(src, dst) trans = cv2.warpPerspective(img, M, img.shape[1::-1], flags=cv2.INTER_LINEAR) trans_on_test.append(trans) thresh = [] binary_wrapeds = [] histogram = [] for img in undistorted: x_thresh = utils.abs_sobel_thresh(img, orient='x', thresh_min=55, thresh_max=100) mag_thresh = utils.mag_thresh(img, sobel_kernel=3, mag_thresh=(70, 255)) dir_thresh = utils.dir_threshold(img, sobel_kernel=3, thresh=(0.7, 1.3)) s_thresh = utils.hls_select(img,channel='s',thresh=(160, 255)) s_thresh_2 = utils.hls_select(img,channel='s',thresh=(200, 240)) white_mask = utils.select_white(img) yellow_mask = utils.select_yellow(img) combined = np.zeros_like(mag_thresh) # combined[(x_thresh==1) | ((mag_thresh == 1) & (dir_thresh == 1)) | (s_thresh==1)] = 1 # combined[((mag_thresh == 1) & (dir_thresh == 1))] = 1 combined[((x_thresh == 1) | (s_thresh == 1)) | ((mag_thresh == 1) & (dir_thresh == 1))| (white_mask>0)|(s_thresh_2 == 1) ]=1 src = np.float32([[(203, 720), (585, 460), (695, 460), (1127, 720)]]) dst = np.float32([[(320, 720), (320, 0), (960, 0), (960, 720)]]) M = cv2.getPerspectiveTransform(src, dst) binary_warped = cv2.warpPerspective(combined, M, img.shape[1::-1], flags=cv2.INTER_LINEAR) hist = np.sum(binary_warped[binary_warped.shape[0]//2:,:], axis=0) histogram.append(hist) binary_wrapeds.append(binary_warped)
thresh = [] binary_wrapeds = [] histogram = [] for img in undistorted: x_thresh = utils.abs_sobel_thresh(img, orient='x', thresh_min=55, thresh_max=100) mag_thresh = utils.mag_thresh(img, sobel_kernel=3, mag_thresh=(70, 255)) dir_thresh = utils.dir_threshold(img, sobel_kernel=3, thresh=(0.7, 1.3)) s_thresh = utils.hls_select(img, channel='s', thresh=(160, 255)) s_thresh_2 = utils.hls_select(img, channel='s', thresh=(200, 240)) white_mask = utils.select_white(img) yellow_mask = utils.select_yellow(img) combined = np.zeros_like(mag_thresh) # combined[(x_thresh==1) | ((mag_thresh == 1) & (dir_thresh == 1)) | (s_thresh==1)] = 1 # combined[((mag_thresh == 1) & (dir_thresh == 1))] = 1 combined[((x_thresh == 1) | (s_thresh == 1)) | ((mag_thresh == 1) & (dir_thresh == 1)) | (white_mask > 0) | (s_thresh_2 == 1)] = 1 src = np.float32([[(203, 720), (585, 460), (695, 460), (1127, 720)]]) dst = np.float32([[(320, 720), (320, 0), (960, 0), (960, 720)]]) M = cv2.getPerspectiveTransform(src, dst) binary_warped = cv2.warpPerspective(combined, M, img.shape[1::-1], flags=cv2.INTER_LINEAR)