ingenuitas/SimpleCV — pull request #208 by vijaym123 (2012-08-17 12:47:12+00:00)
Title: More changes to StereoImage class and StereoCamera class added

Hi,
I have added many changes in these 3 commits.

__1st Change :__
I have changed the name of class named 'StereoCamera' to 'StereoImage'. I have made this change as It makes more sense because it deals with pair of Image (captured from a pair of webcam).

Eg :
```python
img1 = Image("sampleimages/stereo_view1.png")
img2 = Image("sampleimages/stereo_view2.png")
stereoImg = StereoImage(img1,img2)
F,pts1,pts2 = stereoImg.findFundamentalMat()
```
__2nd Change :__
I have changed few parameters used for finding disparity map. Like WindowSize and other parameters.

__3rd Change :__
Stereo Camera is a class dedicated for calibration stereo camera. It also has functionality for rectification and getting undistorted Images.

For calibrating stereo camera's :
```python
StereoCam = StereoCamera()
calib = StereoCam.stereoCalibration(1,2, nboards=30, chessboard=(8,5), gridsize=0.027, WinSize = (352,288))
```
where calib is a tuple (CM1, CM2, D1, D2, R, T, E, F),
CM1 and CM2 are Camera Matrix of both the cameras,
D1 and D2 are Distortion co-efficient,
R is rotation matrix,
T is translation matrix,
E is essential matrix,
F is fundamental matrix.

For saving calibration :
```python
StereoCam = StereoCamera()
calibration = StereoCam.StereoCalibration(1,2,nboards=40)
StereoCam.saveCalibration(calibration,fname="Stereo")
```
The above statement will save the all the calibrations in separate files as :
->StereoCM1.txt
->StereoCM2.txt
->StereoD1.txt
->StereoD2.txt
->StereoR.txt
->StereoT.txt
->StereoE.txt
->StereoF.txt

The saved files can later be loaded into the program using loadCalibration function :
Eg :
```python
StereoCam = StereoCamera()
loadedCalibration = StereoCam.loadCalibration(fname="Stereo")
```

After calibrating we are reminded of rectification parameters and it can be done using the function stereoRectify
Eg :
```python
StereoCam = StereoCamera()
calibration = StereoCam.loadCalibration(fname="Stereo1")
rectification = StereoCam.stereoRectify(calibration)
```
rectification is another tuple of the form (R1, R2, P1, P2, Q, roi)
where R1 and R2 are Rectification transform (rotation matrix)
P1 and P2 are Projection matrix in the new (rectified) coordinate systems
Q is disparity-to-depth mapping matrix
roi is region of interest

Finally to get rectified Images
```python
StereoCam = StereoCamera()
calibration = StereoCam.loadCalibration(fname="Stereo1")
rectification = StereoCam.stereoRectify(loadedCalibration)
imgLeft = camLeft.getImage()
imgRight = camRight.getImage()
rectLeft,rectRight = StereoCam.getImagesUndistort(imgLeft,imgRight,calibration,rectification)
```
Where rectLeft and rectRight are rectified images.

I have added all the necessary documentation and test cases(test_stereovision.py) .
Thank you :)