The flash light field viewer used in the light field archive, and this document, were written by Andrew Adams.
The viewer was written in flex/actionscript using the free flex 3.0 sdk from Adobe.
The viewer source and binary are available here: aperture.zip
The URLS the viewer uses look something like this:
http://lightfield.stanford.edu/aperture.swf?lightfield=data/foo/preview.zip&zoom=1
If you go ahead and download one of those zip files (such as this one of jelly beans). You'll see that they contain a large number of jpeg files, a single xml file, and sometimes a depth map called depth.png. Don't worry about the depth map for now.
The jpegs are the subaperture views. They are rectified views of the scene from many different directions. For the light fields here, I've encoded the filenames to include the position they were taken from (refered to as the (u, v) coordinates), but this is not necessary - the xml file will specify the (u, v) coordinates.
The xml file looks something like this:
<lightfield>
<subaperture src="subapertureview_1.jpg" u="123.4" v="567.8" />
<subaperture src="subapertureview_2.jpg" u="999.2" v="-56" />
<subaperture src="subapertureview_3.jpg" u="9.9" v="0" />
...
</lightfield>
So, to make your own .zip file that will work with the viewer, create an xml file like the one above. It doesn't matter what it's called - the viewer just looks for a file that ends in xml. Remember that xml is more strict that html. You need to close every tag and put every attribute inside quotes. Next, put the xml file and all the subaperture images inside a zip file together. It's probably best not to use any directory structure inside the zip file.
The final step is to inject a special checksum into the zip file to keep the third-party zip-file-handling library I use happy. Aperture.zip, linked above, includes fzip-prepare.py which is a python script that does this:
python fzip-prepare.py myzipfile.zip
You can now view your light field locally using a URI like this:
file:///C:/(some directory)/aperture_local.swf?lightfield=(some relative path)/myzipfile.zip&zoom=1
Or you can put it on a web page like so:
http://(some server)/(some directory)/aperture.swf?lightfield=(some relative path)/myzipfile.zip&zoom=1
The depth maps I use encode depth as disparity, with a certain scale and offset. Here's the procedure you should use to calculate a depth map in a way that the viewer can handle:
Finally, modify your xml file to refer to the computed depth map, and include it in your zip archive.
<lightfield depth="depth.png">
<subaperture src="subapertureview_1.jpg" u="123.4" v="567.8" />
<subaperture src="subapertureview_2.jpg" u="999.2" v="-56" />
<subaperture src="subapertureview_3.jpg" u="9.9" v="0" />
...
</lightfield>
Depending on where your reference plane was, and how much parallax you had, the focus slider may have fairly useless bounds. It defaults to +/-50 in the disparity space descibed above. To change these bounds, modify your xml file like so:
<lightfield fmin="-200" fmax="200">
<subaperture src="subapertureview_1.jpg" u="123.4" v="567.8" />
<subaperture src="subapertureview_2.jpg" u="999.2" v="-56" />
<subaperture src="subapertureview_3.jpg" u="9.9" v="0" />
...
</lightfield>
Changing the focal range like this doesn't play that well with including a depth map. You can do both, provided that fmax < 127, and fmin = -fmax.
Feel free to do whatever you want with the viewer. If you do something cool with it, I'd love to hear about it.
To compile the viewer, ensure that the flex compiler mxmlc is in your path, and issue the command:
mxmlc -system.include-libraries=fzip.swc aperture.mxml
To compile the viewer for local use (ie using file:/// URIs instead of web addresses), add the following flag:
mxmlc -system.include-libraries=fzip.swc aperture.mxml --use-network=false
The viewer also uses a third party zip-file-handling class library called fzip. You don't need to download anything extra - a binary is included in the zip file above.
© 2008 Stanford Graphics Laboratory
Created by Vaibhav Vaish. Updated by Andrew Adams.
Last update:
June 5, 2009 08:04:11 AM