Sunday, January 24, 2010

Stereometry

3D imaging is of vast importance in many fields such as biomedicine, computer vision and other industrial applications. There are different ways of obtaining the three-dimensional reconstruction of an object. These include stereo imaging, structured illumination, photometric stereo and structure from motion. Among all these methods, stereo imaging can be classified as the primary technique from where some of these methods are based.

Stereo imaging depicts how the human eye works. In this technique two cameras are used to capture the image of a test object. The disparity of points from the two images is used to reconstruct the 3D of the object. To further understand this, let’s consider Figure 1.




Figure 1: Model of stereo imaging

As can be seen in Figure 1, two cameras that are coplanar with one another are apart by a distance called the baseline (B). It is assumed that the cameras are identical and are perfectly aligned such that only the locations of their origin differ. If an object with world coordinates (X, Y, Z) is captured by both of these cameras, the object will be seen by camera1 at (x1, y1) with world coordinates at (X1,Y1,Z1) and by camera2 at (x2, y2) with world coordinates (X2,Y2,Z2). From the similar triangles seen at the location of the first camera, the following relation can be deduced


This is similar for the second camera. Hence we can also write,


It should be observed that the Z seen at both of the cameras are equal. Thus it follows that,

Substituting Equation 3 to Equation 1 and solving for Z yields,

The equation for Z tells us that the depth or the height of a test object is dependent on the focal length of the camera, the baseline or the distance between the two cameras and the difference between the corresponding image coordinates along the x axis.


In this activity we render the shape of a box using stereo imaging. Figure 2 shows the stereo images of the box obtained.

Figure 2: Stereo images of a box with baseline equal to 10cm, and focal length of 4.2cm


Using the Rquation for Z, the real world coordinates of the box were solved. Plotting these points, the 3D reconstruction of the object was rendered. This is shown in Figure 3.


Figure 3: Rendered surface of the box.

Since the obtained values for the X, Y and Z are in pixels, these were multiplied by some calibration constants obtained by placing an object with known dimensions. For this purpose, a chess board known to have squares of side 2.5cm was used to obtain the x any y calibration constant. The Z calibration constant used is the same as the X calibration constant.


The 3D reconstruction of the box shown in Figure 3 was obtained by using seven points. As can be observed the reconstruction was able to get the shape of the box. To verify the accuracy of the reconstruction, the Euclidean distances between points constituting sides n, o and m in the reconstruction were calculated. These sides were found to have a value of 8.6cm, 8.2cm and 8cm respectively. Sides m, n and o should have the same value. However the calculated value of the sides doesn’t show this. This error is due to the dependence of Z in the difference of corresponding points in the images. In reconstructing the box, we manually pointed corresponding points from the stereo images. Point mismatch by some pixel can introduce error in the final reconstruction. This problem is actually the main dilemma in stereo imaging and is known as the correspondence problem.