This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import numpy as np | |
| import cv2 | |
| import glob | |
| import matplotlib.pyplot as plt | |
| # prepare object points, like (0,0,0), (1,0,0), (2,0,0) ....,(6,5,0) | |
| objp = np.zeros((6*9,3), np.float32) | |
| objp[:,:2] = np.mgrid[0:9, 0:6].T.reshape(-1,2) | |
| # Arrays to store object points and image points from all the images. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import numpy as np | |
| import cv2 | |
| import glob | |
| import matplotlib.pyplot as plt | |
| # prepare object points, like (0,0,0), (1,0,0), (2,0,0) ....,(6,5,0) | |
| objp = np.zeros((6*9,3), np.float32) | |
| objp[:,:2] = np.mgrid[0:9, 0:6].T.reshape(-1,2) | |
| # Arrays to store object points and image points from all the images. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Saturation color channel binary threshold. | |
| def s_threshold(img, s_thresh=(0, 255)): | |
| s_channel = cv2.cvtColor(img, cv2.COLOR_BGR2HLS)[:,:,2] | |
| # Threshold color channel | |
| s_binary = np.zeros_like(s_channel) | |
| s_binary[(s_channel >= s_thresh[0]) & (s_channel <= s_thresh[1])] = 1 | |
| return s_binary | |
| # Define a function that takes an image, gradient orientation, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Define a function to return the magnitude of the gradient | |
| # for a given sobel kernel size and threshold values | |
| def mag_thresh(img, sobel_kernel=3, mag_thresh=(0, 255)): | |
| # Convert to grayscale | |
| gray = cv2.cvtColor(img, cv2.COLOR_RGB2GRAY) | |
| # Take both Sobel x and y gradients | |
| sobelx = cv2.Sobel(gray, cv2.CV_64F, 1, 0, ksize=sobel_kernel) | |
| sobely = cv2.Sobel(gray, cv2.CV_64F, 0, 1, ksize=sobel_kernel) | |
| # Calculate the gradient magnitude | |
| gradmag = np.sqrt(sobelx**2 + sobely**2) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import numpy as np | |
| import cv2 | |
| import matplotlib.pyplot as plt | |
| import matplotlib.image as mpimg | |
| import pickle | |
| # Read in an image and grayscale it | |
| image = mpimg.imread('signs_vehicles_xygrad.png') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Define a function that takes an image, number of x and y points, | |
| # camera matrix and distortion coefficients | |
| def corners_unwarp(img, nx, ny, mtx, dist): | |
| # Use the OpenCV undistort() function to remove distortion | |
| undist = cv2.undistort(img, mtx, dist, None, mtx) | |
| # Convert undistorted image to grayscale | |
| gray = cv2.cvtColor(undist, cv2.COLOR_BGR2GRAY) | |
| # Search for corners in the grayscaled image | |
| ret, corners = cv2.findChessboardCorners(gray, (nx, ny), None) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import csv | |
| import cv2 | |
| import numpy as np | |
| # Data read from csv. CSV contains the image path and steerig angles recorded at various points of gameplay. | |
| lines = [] | |
| csvPath = "/Users/hackintoshrao/Documents/code/self-drive/driving_log.csv" | |
| with open(csvPath) as csvData: | |
| # read from csv |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import numpy as np | |
| import cv2 | |
| import matplotlib.pyplot as plt | |
| import matplotlib.image as mpimg | |
| # prepare object points | |
| nx = 8# enter the number of inside corners in x | |
| ny = 6# enter the number of inside corners in y | |
| # Make a list of calibration images |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import csv | |
| import cv2 | |
| import numpy as np | |
| # Data read from csv. CSV contains the image path and steerig angles recorded at various points of gameplay. | |
| lines = [] | |
| csvPath = "/Users/hackintoshrao/Documents/code/self-drive/driving_log.csv" | |
| with open(csvPath) as csvData: | |
| # read from csv |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import ( | |
| "github.com/gorilla/mux" | |
| "net/http/pprof" | |
| "runtime/debug" | |
| "runtime" | |
| runtimepprof "runtime/pprof" | |
| ) | |
| const ( |