Stereoscopy =========== A program (in C) to find the distance to an object using two images and computing distances accross these images (thanks to a stereoscopy algorithm). ## Usage This program computes the mean distance between a stereoscopic camera and an object. We assume both cameras have the same specs (which are the diameter of the field stop of the cameras and the focal length). The idea behind this software is very simple. First, it tries to determine the distance in pixels between the same element through the two photos (either by using a FFT-based approach or by comparing patterns from the two pictures). Once it gets the distance in pixels through the two pictures, it can easily convert it to a real distance between the camera and the object, using the specifications of the camera. For more details about the way I convert a distance in pixels to a real (perpendicular) distance in centimeter, please refer to the following article (I just used the formulas in this paper without major modifications) : http://docs.lib.purdue.edu/cgi/viewcontent.cgi?article=1064&context=ecetr This software was tested successfully (_ie_ giving a result correct according to the incertitude on the camera specs) with a standard compact camera, taking two pictures separated by a few centimeters (to mimmic our eyes). ### Notes : * I use the OpenCV library to easily load and go through the images. OpenCV is a C library for computer vision licensed under a BSD License ( http://opensource.org/licenses/bsd-license.php ) * The software computes both X and Y displacements but will focus on X displacements to determine the mean distance of the object as the cameras are supposed to be on the same horizontal plane (Y displacements are vertical displacements and should be negligible). It is possible to take into account a vertical displacement with minor modification to the code (you should just find a correct formula in 3D :) * X corresponds to the abscissa and Y to the ordinate of the pixel in the image. They both goes from 0 to the size of your image. * It has been successfully tested on a **GNU/Linux** system. I think it could work on Windows with minor or no modifications but haven't try. Pixels are numeroted this way :
(0,0) (1,0) (2,0) ... (Width,0) (1,0) (1,1) (2,1) ... (Width,1) ... ... ... ... ... (0,Height) ... ... ... (Width, Height)## Compiling You must have opencv libs installed on your system. ## Command line arguments