views:

231

answers:

0

Hi everyone,

I've been using the great Emgu C# wrapper for OpenCV to collect images from a home built stereo rig. Two webcams bolted down to a piece of wood, 35cm apart to hopefully let me produce depth maps in the 10-20m range. I've set them up to be as parallel as I can make it (about 89.3 degrees from a triangulation test).

I'm trying to make a disparity map from these and although the process works as code the results are very random. By this I mean each time I attempt to run the stereo rectify I get very different results and the image is often so badly warped there is hardly anything to see on screen.

As I understand it the way to do this is as follows:


1) Print off a chessboard pattern (e.g 6 by 8 inner corners)- stick onto something flat.

2) Take a set of about 10 photos from camera 1 holding the chess board in full view but different positions.

3) use CameraCalibration.FindChessboardCorners to find the inner corners (6 by 8)

4) use img.FindCornerSubPix() to refine these corner locations to subpixel level

5) use CameraCalibration.CalibrateCamera() to calculate the intrinsic camera details, and save this as an XML file

6) Repeat above for camera 2.

7) Now you have the internal camera distortion information you can take a stereo photo pair and use CameraCalibration.StereoCalibrate() with the intrinsic data previously calculated to work out the extrinsic information (offsets and rotations between camera 1 and 2).

8) Use CvInvoke.cvStereoRectify() and CvInvoke.cvInitUndistortRectifyMap() and then CvInvoke.cvRemap() to build an output image which should be lined up in Y so you can run one of the stereo correspondence tests.

I found you need to be using Emgu 2.1 ver 806 to get the cvStereoRectify to work without an Access Violation error.


I guess my questions are:

A) Is my process correct? I've been doing the camera intrinsic calibration as a separate process because as the cameras are 35cm apart it's not easy to get the chessboard in view of both of them in the office and move it around much.. as it soon goes off the side of one of the camera views. I figured that as the values are intrinsic these are related to the camera and therefore should transfer to the stereo procedure OK. Is this correct?

It seems that the intrinsic values are getting altered during the cvStereoRectify process, and are being made very different.

eg. Distortion values from first stage = 0.22,-1.2,0.01,-0.01,2.6 after cvStereoRectify the values were changed to= 10,-489,-0.03,-0.09,13208

I'm no expert but the first set seem to be more like what I'd seen from other people's comments, and the second set seem pretty way out!

B) Is there any way to stop the intrinsic + distortion values being updated during cvStereoRectify?

C) Does this seem right for the intrinsic values (937,0,290,0,932,249,0,0,1)?

Thanks very much for any tips... I've been stuck on this for a while now... and I'm really not sure which part of the process is throwing up the errors. Any tips or suggestions would be very welcome...