'**SUMMARY**
If given an image, apply the undistortion given by the camera\'s matrix and return the result.
If given a 1xN 2D cvmat or a 2xN numpy array, it will un-distort points of
measurement and return them in the original coordinate system.
**PARAMETERS**
* *image_or_2darray* - an image or an ndarray.
**RETURNS**
The undistorted image or the undistorted points. If the camera is un-calibrated
we return None.
**EXAMPLE**
>>> img = cam.getImage()
>>> result = cam.undistort(img)'

def undistort(self, image_or_2darray):

    if ((type(self._calibMat) != cv.cvmat) or (type(self._distCoeff) != cv.cvmat)):
        logger.warning('FrameSource.undistort:    This    operation    requires    calibration,    please    load    the    calibration    matrix')
        return None
    if ((type(image_or_2darray) == InstanceType) and (image_or_2darray.__class__ == Image)):
        inImg = image_or_2darray
        retVal = inImg.getEmpty()
        cv.Undistort2(inImg.getBitmap(), retVal, self._calibMat, self._distCoeff)
        return Image(retVal)
    else:
        mat = ''
        if (type(image_or_2darray) == cv.cvmat):
            mat = image_or_2darray
        else:
            arr = cv.fromarray(np.array(image_or_2darray))
            mat = cv.CreateMat(cv.GetSize(arr)[1], 1, cv.CV_64FC2)
            cv.Merge(arr[:, 0], arr[:, 1], None, None, mat)
        upoints = cv.CreateMat(cv.GetSize(mat)[1], 1, cv.CV_64FC2)
        cv.UndistortPoints(mat, upoints, self._calibMat, self._distCoeff)
        return ((np.array(upoints[:, 0]) * [self.getCameraMatrix()[(0, 0)], self.getCameraMatrix()[(1, 1)]]) + [self.getCameraMatrix()[(0, 2)], self.getCameraMatrix()[(1, 2)]])[:, 0]
