Implementation of Photorealistic Scene Reconstruction by Voxel Coloring

Daniel Archambault
University of British Colombia
Department of Computer Science

Purpose


    The following pages provide documentation to use my implementation of voxel colouring presented by Steven Seitz and Charles Dyer in [2] and [3].  This implementation was undertaken as a course project for CPSC 514:  Advanced Computer Graphics taught by Wolfgang Heidrich in 2002.  The formal write up of the project can be found here.
 

Camera Setup


    The setup used to colour the subjects is as demonstrated in the photograph below.  Since a turntable was not available as was used in [2]
and [3], the subject was placed a known distance from the camera and the camera was moved around the subject instead.  The subject and
the calibration grid did not move between photographs and therefore the camera's intrinsic and extrinsic parameters could be inferred from the
images taken.  You may find this procedure usefull in calibrating your images for this system.  More detailes can be found in the report.
 

Calibration Procedure


    For voxel coloring to work properly, we need to know the intrinsic parameters of the camera, and the extrinsic parameters of each view relative to the subject.  These parameters were obtained using a standard calibration grid and the Camera Calibration Toolbox for Matlab developed by Jean-Yves Bouguet [3].  Most of these instructions can be found here.  Your images should have a base name and should be numbered from
1 to n for n images.

1.  Get a the latest copy of the Camera Calibration ToolBox for Matlab from the download page.
2.  Run MatLab
3.  Go to File->Set Path.
4.  Add the path to the current directory as well as the path to the Calibration Toolbox you downloaded in step 1.  Save and Exit.
5.  Run the Calibration Toolbox by typing calib at the prompt.
6.  Choose either standard or memory efficent depending on the size and number of images that you have.
7.  You will then be prompted for your basename and image format (jpg, ppm, etc).  Enter that at the prompt.
8.  Click on Extract grid corners.
9.  For each image, click on the calibration grid's extreme coners.  Start with the origin and click them in either a clockwise or counterclockwise fashion.  The first time you will be promped for the dimensions of a square on your grid.  Enter them at the prompt.
10.  Check to make sure that the tool properly compensated for distortion.  You will be prompted to extract the corners for the next image.  Repeat 9-10 for all images.
11.  Click on the Calibration button in the tool box.  It will work away on the images and present you with the camera's intrinsic parameters (focal length, principal point, skew, and distortion).  Copy these parameters to a file as they will be used later.
12.  Obtain the extrinsic parameters for each camera view.  These are stored in the variables Tc_* (camera translation) and Rc_* (camera rotations) in matlab where * is the image number.  For example, to get the extrinsic parameters for image one simply type Tc_1 and Rc_1 at the Matlab prompt.  Save the camera extrinsic parameters for each image in a file as this data will be used later.
 

Calibration Parameters Datafile Setup


    The following is a description of the file format used to present the calibration data to the voxel colourer.  Note that all calibration parameters are requred as rectification is preformed on the fly as described here.  An example datafile is supplied here.

Number of Images
<start x y z> <end x y z>  The start and end coordinates of the object from the origin of the calibration grid.  Measured in millimeters.
The background colour.  The range of each value must be between 0 - 255.
The corilation window edge size.  Number of pixels of error we will allow for voxel colouring.  Three is advisable.
The focal length.
The principal Point.
The Skew.                                 all of these together are the camera's intrinsic parameters
The Distortion.
The Pixel Error

A listing of the path to each image and the view's extrinsic parameters.
 

Running the Colourer

To run the colourer simply type:

colourer <Resolution> <Parameter Data File> <Output File>

<Resolution> is the resolution of the voxel grid (number of voxels/millimeters cubed).  For good models, this should be one or less than one.
<Parameter Data File> - This is a path to the datafile that was set up in the previous section.
<Output File> - This is the file where the output of the voxel colourer will be written.

The colourer takes about 10 - 20 minutes to run on a resonably sized model (300mm x 300mm x 100 mm).   Progress dots will be printed to
the terminal window at various stages of the colouring.

The Colourer's Output

The colourer's output is relatively easy to understand.  An example datafile is supplied here.  The file format is as follows:
<start x y z>  <end x y z>  <resolution> <number of voxels>
<voxel x y z>  <colour r g b>
...

where:

<start x y z> is the minimum x, y, and z values of the voxel space in millimeters cubed.
<end x y z> is the maxumum x, y, and z values of the voxel space in millimeters cubed.
<resolution> is the resolution of the voxel space (number of voxels/millimeter cubed).
<number of voxels> is the number of coloured voxels in the model
<voxel x y z>  <colour r g b> are the x y and z coordinates of the voxel and its respective colour.  There are precisely <number of voxels> of these in the model.

A vewer for this datafile has been supplied with the colourer (viewer).

Source Code

The source code for the colourer is available here without models.  A few models are available here.

References

[1] Jean-Yves Bouguet,  Camera Calibration Toolbox for Matlab, April 2002.  Available:  http://www.vision.caltech.edu/bouguetj/calib\_doc (May 1, 2002).

[2] Steven M. Seitz, and Charles R. Dyer, Photorealistic Scene Reconstruction by Voxel Coloring in Proc. Computer Vision and Pattern Recognition Conf., pp. 1067-1073, 1997.

[3] Steven M. Seitz, and Charles R. Dyer, Photorealistic Scene Reconstruction by Voxel Coloring, in  Int. Journal of Computer Vision, volume 35, number 2, pp. 151-173, 1999.