'**SUMMARY**
Camera calibration will help remove distortion and fisheye effects
It is agnostic of the imagery source, and can be used with any camera
The easiest way to run calibration is to run the
calibrate.py file under the tools directory for SimpleCV.
This will walk you through the calibration process.
**PARAMETERS**
* *imageList* - is a list of images of color calibration images.
* *grid_sz* - is the actual grid size of the calibration grid, the unit used will be
the calibration unit value (i.e. if in doubt use meters, or U.S. standard)
* *dimensions* - is the the count of the *interior* corners in the calibration grid.
So for a grid where there are 4x4 black grid squares has seven interior corners.
**RETURNS**
The camera\'s intrinsic matrix.
**EXAMPLE**
See :py:module:calibrate.py'

def calibrate(self, imageList, grid_sz=0.03, dimensions=(8, 5)):

    warn_thresh = 1
    n_boards = 0
    board_w = int(dimensions[0])
    board_h = int(dimensions[1])
    n_boards = int(len(imageList))
    board_n = (board_w * board_h)
    board_sz = (board_w, board_h)
    if (n_boards < warn_thresh):
        logger.warning('FrameSource.calibrate:    We    suggest    using    20    or    more    images    to    perform    camera    calibration!')
    image_points = cv.CreateMat((n_boards * board_n), 2, cv.CV_32FC1)
    object_points = cv.CreateMat((n_boards * board_n), 3, cv.CV_32FC1)
    point_counts = cv.CreateMat(n_boards, 1, cv.CV_32SC1)
    intrinsic_matrix = cv.CreateMat(3, 3, cv.CV_32FC1)
    distortion_coefficient = cv.CreateMat(5, 1, cv.CV_32FC1)
    i = 0
    z = 0
    successes = 0
    imgIdx = 0
    while (successes < n_boards):
        found = 0
        img = imageList[imgIdx]
        (found, corners) = cv.FindChessboardCorners(img.getGrayscaleMatrix(), board_sz, (cv.CV_CALIB_CB_ADAPTIVE_THRESH | cv.CV_CALIB_CB_FILTER_QUADS))
        corners = cv.FindCornerSubPix(img.getGrayscaleMatrix(), corners, (11, 11), ((-1), (-1)), ((cv.CV_TERMCRIT_EPS + cv.CV_TERMCRIT_ITER), 30, 0.1))
        if (found == 1):
            corner_count = len(corners)
            z = (z + 1)
        if (len(corners) == board_n):
            step = (successes * board_n)
            k = step
            for j in range(board_n):
                cv.Set2D(image_points, k, 0, corners[j][0])
                cv.Set2D(image_points, k, 1, corners[j][1])
                cv.Set2D(object_points, k, 0, (grid_sz * (float(j) / float(board_w))))
                cv.Set2D(object_points, k, 1, (grid_sz * (float(j) % float(board_w))))
                cv.Set2D(object_points, k, 2, 0.0)
                k = (k + 1)
            cv.Set2D(point_counts, successes, 0, board_n)
            successes = (successes + 1)
    if (successes < warn_thresh):
        logger.warning(('FrameSource.calibrate:    You    have    %s    good    images    for    calibration    we    recommend    at    least    %s' % (successes, warn_thresh)))
    object_points2 = cv.CreateMat((successes * board_n), 3, cv.CV_32FC1)
    image_points2 = cv.CreateMat((successes * board_n), 2, cv.CV_32FC1)
    point_counts2 = cv.CreateMat(successes, 1, cv.CV_32SC1)
    for i in range((successes * board_n)):
        cv.Set2D(image_points2, i, 0, cv.Get2D(image_points, i, 0))
        cv.Set2D(image_points2, i, 1, cv.Get2D(image_points, i, 1))
        cv.Set2D(object_points2, i, 0, cv.Get2D(object_points, i, 0))
        cv.Set2D(object_points2, i, 1, cv.Get2D(object_points, i, 1))
        cv.Set2D(object_points2, i, 2, cv.Get2D(object_points, i, 2))
    for i in range(successes):
        cv.Set2D(point_counts2, i, 0, cv.Get2D(point_counts, i, 0))
    cv.Set2D(intrinsic_matrix, 0, 0, 1.0)
    cv.Set2D(intrinsic_matrix, 1, 1, 1.0)
    rcv = cv.CreateMat(n_boards, 3, cv.CV_64FC1)
    tcv = cv.CreateMat(n_boards, 3, cv.CV_64FC1)
    cv.CalibrateCamera2(object_points2, image_points2, point_counts2, (img.width, img.height), intrinsic_matrix, distortion_coefficient, rcv, tcv, 0)
    self._calibMat = intrinsic_matrix
    self._distCoeff = distortion_coefficient
    return intrinsic_matrix
