Archive

Tag Archives: CHDK

3d stereo experiments.009

Yogi from Mars 3D

Going off-piste again this week, kinda. Randomly, I wondered just how easy it would be to capture and process stereo 3D timelapse with open-source tools. Having mostly ignored 3D, and being largely unimpressed by its cinema application, I was still wondering what the killer application for stereoscopic photography.

These days, a number of single lens cameras have a “3D” function which stitches together a number of exposures into a navigable image that allows the point-of-view (POV) to be changed, interactively. To my mind this is not really 3D, it’s like the moving lenticular images we used to collect in the 1970s. What I am interested in is true stereoscopic imaging, which requires genuine binocular vision to give a convincing effect of depth.

Tim Dashwood has written an excellent introduction to stereo/3D photography that I do not intend to duplicate, but what I am going to cover is the specifics of doing it with CHDK, FFMpeg and ImageMagick.
http://www.dashwood3d.com/blog/beginners-guide-to-shooting-stereoscopic-3d/

This is just an introductory blog post and I’m not going to get to any workflows just yet.

Stereo imaging has been around since 1840, almost as long as photography itself, and here are some amazing stereographs captured during American Civil War.
http://www.theatlantic.com/infocus/2012/02/the-civil-war-part-3-the-stereographs/100243/

Some of these give away the fact that they were show with one camera in two positions.

Landscape

I was introduced to stereoscopic 3D it in the 1970s via my sister’s View-Master, but this was not much more sophisticated than the widely available stereo viewers from the nineteenth and early twentieth centuries.

Stereoscoop_VM

The documented optimum lens separation for human vision is 65mm, give or take, and my eyes are pretty much exactly that distance apart. However, according to various sources larger separations work fine for some subjects and for landscapes and distant objects, a larger separations will work fine. I will be doing some tests with different sized subjects.

For reference, I am not interested in red/cyan anaglyph type image, because of the weird colour effects, but I am going to use this technique for the sake of being able to display them on vanilla monitors. Not everyone can do it, but I can also do the cross-eyed right-left trick too, although it’ not practical for any length of time.

Recently, I bought a 3D LED TV that supports passive polarised glasses and I saw an excellent demo of a Fujifilm W3 3D camera displaying media on LG monitors at a photography trade show in 2010.

There are some excellent existing resources for shooting stereographs with CHDK, including the StereoDataMaker site, and Gentles Ltd, and I’ll add more info about other resources soon.

I have mixed feelings about 3D and am not sure just what I really want to do with it, but how hard can it be? I was not sure how to prepare the media and assumed it would be more difficult than it is. Turns out processing pairs of images is very easy in ImageMagick, and as far as the polarised light monitors go, all the cleverness is done in the screen so you just have to give it 2 images side-by-side.

It never occurred to me that it would be so easy.

So, side-by-side is my eventual destination format, but using red/cyan anaglyph for convenience and online dissemination.

Anyway, I’m running out of time, but I might update this post later. In the meantime here are a few links and I’ll post more soon with come code and practical tests.

Stereoscopy.com
http://www.stereoscopy.com/gallery/

History of Sterography
http://www.arts.rpi.edu/~ruiz/stereo_history/text/historystereog.html

Advertisements

A640 rotated_84_2

Having been flying around the country over the past couple of weeks, I’ve shot a lot of timelapse out of the front windscreen. Just because I can.

It’s largely thanks to CHDK and I have managed to record myself getting lost on routes between Sheffield, Lancaster, Leeds, Newcastle, Nottingham and York. I have a few plans for this media, but one journey is already online here:

This was quite a successful Flying Monkey TV experiment and I had it edited and online within three hours of getting home.

These journeys were mostly shot on a Canon PowerShot A560, timelapse-enable with CHDK, and mounted on the inside of the front windscreen with a suction mount (see below). I mounted the camera hanging from the top of the screen, upside down. This meant that it was in line with the passenger side roof pillar and hence did not obscure my view.

I don’t use the auto-rotate feature in most cameras because it sometimes gets confused and can give you a few incorrectly rotated frames here and there. Consequently, shooting this way, I end up with an upside-down video that then needs rotating.

559CANON_full_2048_03pct

I used to drop them into Final Cut Pro, render them and export them to a new movie file, which works fine, but I think it’s time to write a Bash script to do it.

No sooner said than done! Well, not quite, but it was much easier than I imagined. As usual Google managed to find some very helpful resources for me to cannibalise. Writing the code is much faster than documenting it into a usable blog post.

I started by reminding myself how to create a basic for-next procedure (detail included here for other noobs). Here is a bit of basic code with lists the files in the present working directory ending in “.JPG” (don’t forget this is case-sensitive) and echos them to the screen. The semicolons separate the statements and the “done” terminates it.

for i in $(ls *.JPG); do echo $i; done

For the next step, instead of just listing the file names to the screen, I added the ImageMagick step to rotate the image and write it over the original.

for i in $(ls *.JPG); do convert $i -rotate 180 $i; done

As you might have already gathered, I like some progress feedback so added an echo with the file count and file name.

for i in $(ls *.JPG); do convert $i -rotate 180 $i; x=$(($x+1)) ;echo “$i $x”; done

However, a current file number is only of use if you know how many more to go. A bit of googling revealed this forum thread and the code:

ls -l | wc -l

This lists all the files in the current directory and then pipelines that list to give an integer count of the items in that list. It’s not necessary if this is just a temporary folder and it’s cleared between uses, but if you want to filter the file types you can add a wild card search like this:

ls -l *.JPG | wc -l

I found information about the two commands on linux.about.com and a forum thread which combines the two on unix.com.
http://linux.about.com/od/commands/l/blcmdl1_ls.htm
http://linux.about.com/library/cmd/blcmdl1_wc.htm
http://www.unix.com/unix-dummies-questions-answers/36490-ls-command-listing-number-files.html

So my final piece of code (for this iteration at least) is here:

x=0; c=$(ls -l *.JPG | wc -l); for i in $(ls *.JPG); do convert $i -rotate 180 $i; x=$(($x+1)) ;echo “$x /$c $i”; done

This sets x to be 0, c to be the number of files with filenames ending in “.JPG” in the current directory, rotates each one of them by 180 degrees, overwrites the original file and echos the file number, the file count and the filename. It’s pretty basic and I’ll roll it into a script soon.

There may well be better ways of doing this, but it worked well as an exercise to reinforce my learning.

This is how I imagine myself, but I think I would stand somewhere else. (Photo: archive.org)

Q. Why are we doing this?

Flying Monkey TV was conceived as a collaborative documentary filmmaking project using low-impact methods and available technology.

A. Because we can. Because it’s a great idea. Because we want to.

We have had a small amount of funding in 2010 from Arts Council England, via The Culture Company,  but the project is currently unfunded. However, I decided to embark upon the development stage of getting the FMTV software up and running so that we can use it to do more critical content tests.
http://www.artscouncil.org.uk/
http://www.theculturecompany.co.uk/

Having knocked about at Access Space for many years, I am acutely aware of how much redundant technology is lying around, unused or at least underused. So, I decided to try and press some of these sleeping monkeys into service in order to get more horsepower(?) for the unenviable task of post-processing.
http://access-space.org

As I keep saying, shooting is easy, and that’s the problem. I am developing ways of using old computers to post-process the hundreds of gigabytes of timelapse media that I can capture on the two-dozen or so CHDK-enabled Canon Powershot cameras that I have.
http://CHDK.wikia.com

My aim is to learn Bash-shell UNIX commands and programming on Linux-based machines so that we can create a suite of software tools to compile, scale, crop etc images files into movie files. Some of these tools may exist already, and our aim is to use what exists, and create what doesn’t.

Q. Why run Linux on a Mac?

I do not necessarily need OS X at all for my purposes, but it’s very convenient to have a mature and stable GUI on any machine. After some research and advice from Access Space, it seems that using the freely available Linux libraries gPhoto2 (for accessing the on-camera files) FFMpeg (for assembling images into movies), and (amongst others) ImageMagick for manipulating images.
http://gphoto.org/
http://ffmpeg.org/
http://www.imagemagick.org/

A. Because we’ve got some, and they’re not doing anything else.

Many of these libraries are also available for OS X Macs via the MacPorts project, and I will be doing some performance comparison tests to see which route is more efficient.
http://www.macports.org/

Q. So if I can run Shell scripts on OS X anyway, why use Linux at all?

Access Space has a very strict policy of using free, open-source and legal software. I am not as philosophically pure, but I like to remain legal. At home all my Macs run on a retail multi-license of Snow Leopard, but as far as I am aware, I cannot buy earlier versions of OS X, and in the absence of the original install disks, Linux is the only legal choice.

Actually, installing Ubuntu on a PowerMac G4 was pretty trivial, but not at first.

The first attempt was using the Debian 6.0.4 PowerPC net install image from a CD boot disk. This worked fine until reboot, and then left me with a black screen. The install seemed to have gone fine but I was unable to get it to drive the monitor correctly once the GUI started. After 4 hours of clutching at straws and unsuccessful editing of the Xorg file I decided to try another approach.

With the help of Access Space, the second attempt was much more successful, using a downloaded CD image of Ubuntu Linux 10.04 Lucid Lynx, and it worked first time. This was on a 450 Mhz PowerMac G4 with 256 Mb RAM, although it did feel a bit sluggish, probably due to the low memory.
http://cdimage.ubuntu.com/ports/releases/lucid/release/

As an additional test, I installed Ubuntu 10.10 on another G4 and then followed the upgrade path suggested by the installer to 11.04 Natty Narwhal, but this led to hundreds of error messages during install and failure to boot. So, for the time being I’m sticking to 10.04 on the PowerMac G4.

One other G4 failed to boot after install but I suspect it is a hardware error with the hard disk, rather than the software.

I also created a dual boot on my first-generation, and distinctly cranky, MacBook 1.8 Hhz Core Duo, with OS X 10.6 Snow Leopard on the Mac partition and Ubuntu 11.10  Oneiric Ocelot on the other partition. The partition was created using the Bootcamp utility and the installation was performed from a CD boot disk from Ubuntu.
http://releases.ubuntu.com/11.10/

I also installed the rEFit boot menu as detailed in this how-to guide.
http://scottlinux.com/2011/06/14/how-to-dual-boot-os-x-and-linux/

I also installed MacPorts in order to use the same libraries, but it is unreliable on this machine. I believe it is the knackered old Macbook that is the problem, and I have MacPorts working fine on other machines.

A. Macs are relatively expensive and my purpose is utility, so that I can use the Macs that I’ve got, but also press PCs into service as I stumble over them.