Skip to content

Instantly share code, notes, and snippets.

View gonzaloruizdevilla's full-sized avatar

Gonzalo Ruiz de Villa gonzaloruizdevilla

  • GFT
  • Madrid, Spain
View GitHub Profile
@gonzaloruizdevilla
gonzaloruizdevilla / sobel.py
Created August 17, 2018 10:32
Direction of the Gradient Sobel
import numpy as np
import cv2
import matplotlib.pyplot as plt
import matplotlib.image as mpimg
import pickle
# Read in an image
image = mpimg.imread('signs_vehicles_xygrad.png')
import matplotlib.pyplot as plt
import matplotlib.image as mpimg
import numpy as np
import cv2
# Read in an image, you can also try test1.jpg or test4.jpg
image = mpimg.imread('test6.jpg')
# Define a function that thresholds the S-channel of HLS
# Use exclusive lower bound (>) and inclusive upper (<=)
@gonzaloruizdevilla
gonzaloruizdevilla / color_gradient.py
Created August 18, 2018 09:28
Color and gradient
import numpy as np
import cv2
import matplotlib.pyplot as plt
import matplotlib.image as mpimg
image = mpimg.imread('bridge_shadow.jpg')
# Edit this function to create your own pipeline.
def pipeline(img, s_thresh=(170, 255), sx_thresh=(20, 100)):
@gonzaloruizdevilla
gonzaloruizdevilla / locatelines.py
Created August 19, 2018 08:20
Locate the Lane Lines
import numpy as np
import matplotlib.image as mpimg
import matplotlib.pyplot as plt
# Load our image
# `mpimg.imread` will load .jpg as 0-255, so normalize back to 0-1
img = mpimg.imread('warped_example.jpg')/255
def hist(img):
# TO-DO: Grab only the bottom half of the image
@gonzaloruizdevilla
gonzaloruizdevilla / sliding.py
Last active August 20, 2018 13:35
Finding the Lines: Sliding Window
import numpy as np
import matplotlib.image as mpimg
import matplotlib.pyplot as plt
import cv2
# Load our image
binary_warped = mpimg.imread('warped_example.jpg')
def find_lane_pixels(binary_warped):
# Take a histogram of the bottom half of the image
@gonzaloruizdevilla
gonzaloruizdevilla / prior.py
Created August 20, 2018 14:39
Finding the Lines: Search from Prior
import cv2
import numpy as np
import matplotlib.image as mpimg
import matplotlib.pyplot as plt
# Load our image - this should be a new frame since last time!
binary_warped = mpimg.imread('warped_example.jpg')
# Polynomial fit values from the previous frame
# Make sure to grab the actual values from the previous step in your project!
@gonzaloruizdevilla
gonzaloruizdevilla / curv1.py
Created August 20, 2018 16:34
Measuring curvature 1
import numpy as np
def generate_data():
'''
Generates fake data to use for calculating lane curvature.
In your own project, you'll ignore this function and instead
feed in the output of your lane detection algorithm to
the lane curvature calculation.
'''
# Set random seed number so results are consistent for grader
@gonzaloruizdevilla
gonzaloruizdevilla / curv2.py
Created August 21, 2018 09:29
Measuring Curvature II
import numpy as np
def generate_data(ym_per_pix, xm_per_pix):
'''
Generates fake data to use for calculating lane curvature.
In your own project, you'll ignore this function and instead
feed in the output of your lane detection algorithm to
the lane curvature calculation.
'''
# Set random seed number so results are consistent for grader
@gonzaloruizdevilla
gonzaloruizdevilla / index.js
Created September 14, 2018 11:40
Y Combinator in JavaScript
let almost_factorial = f => n => n == 0 ? 1 : n * f(n-1)
//This first version is not yet a combinator
let Y1 = f => f (x => Y1(f)(x))
let factorial = (almost_factorial(x => (Y(almost_factorial)(x))))
console.log(factorial(6))
//720
/*The strict (applicative-order) Y combinator*/
let Y2 = f => (x => x(x))(x => f(y => x(x)(y)))
let factorial2 = Y2(almost_factorial)
@gonzaloruizdevilla
gonzaloruizdevilla / kalman_filter.py
Created November 20, 2018 00:08
Kalman Matrices
# Write a function 'kalman_filter' that implements a multi-
# dimensional Kalman Filter for the example given
from math import *
class matrix:
# implements basic operations of a matrix class