{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "## Advanced Lane Finding Project\n", "\n", "The goals / steps of this project are the following:\n", "\n", "* Compute the camera calibration matrix and distortion coefficients given a set of chessboard images.\n", "* Apply a distortion correction to raw images.\n", "* Use color transforms, gradients, etc., to create a thresholded binary image.\n", "* Apply a perspective transform to rectify binary image (\"birds-eye view\").\n", "* Detect lane pixels and fit to find the lane boundary.\n", "* Determine the curvature of the lane and vehicle position with respect to center.\n", "* Warp the detected lane boundaries back onto the original image.\n", "* Output visual display of the lane boundaries and numerical estimation of lane curvature and vehicle position.\n", "\n", "---\n", "## First, I'll compute the camera calibration using chessboard images" ] }, { "cell_type": "code", "execution_count": 3, "metadata": { "collapsed": true }, "outputs": [], "source": [ "import numpy as np\n", "import cv2\n", "import glob\n", "import matplotlib.pyplot as plt\n", "%matplotlib qt\n", "\n", "# prepare object points, like (0,0,0), (1,0,0), (2,0,0) ....,(6,5,0)\n", "objp = np.zeros((6*9,3), np.float32)\n", "objp[:,:2] = np.mgrid[0:9,0:6].T.reshape(-1,2)\n", "\n", "# Arrays to store object points and image points from all the images.\n", "objpoints = [] # 3d points in real world space\n", "imgpoints = [] # 2d points in image plane.\n", "\n", "# Make a list of calibration images\n", "images = glob.glob('../camera_cal/calibration*.jpg')\n", "\n", "# Step through the list and search for chessboard corners\n", "for fname in images:\n", " img = cv2.imread(fname)\n", " gray = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)\n", "\n", " # Find the chessboard corners\n", " ret, corners = cv2.findChessboardCorners(gray, (9,6),None)\n", "\n", " # If found, add object points, image points\n", " if ret == True:\n", " objpoints.append(objp)\n", " imgpoints.append(corners)\n", "\n", " # Draw and display the corners\n", " img = cv2.drawChessboardCorners(img, (9,6), corners, ret)\n", " cv2.imshow('img',img)\n", " cv2.waitKey(500)\n", "\n", "cv2.destroyAllWindows()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## And so on and so forth..." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [] } ], "metadata": { "anaconda-cloud": {}, "kernelspec": { "display_name": "Python [conda root]", "language": "python", "name": "conda-root-py" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 2 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython2", "version": "2.7.11" } }, "nbformat": 4, "nbformat_minor": 1 }