Archive

Tag Archives: ImageMagick

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

I’m going a bit off-piste with this post, and looking at the hidden-in-plain-view potential of some of the libraries, very familiar to Linux geeks, but pretty much unknown to the outside world.

Although I talk about the past a lot, I’m not nostalgic. I don’t miss the frustrations of the past. I just like to remind myself how good things are now. By the way, I am by no means a computer historian, and my opinions and experience are subjective. If I post anything that is factually incorrect, please let me know.

I realise some of this might be bleeding obvious to the Linux world, but those of us cloistered for years in the walled-garden of the Mac OS X GUI, it’s quite a revelation.

As I’ve said before, I’m a lapsed programmer and used to write commercial software using framework applications, primarily FileMaker Pro 3.0 amongst others. FileMaker has developed into a very sophisticated rapid application development (RAD) platform now that FileMaker Inc have got around to including the features that us developers were clamouring for in the 1990s.

Given a choice, I am very happy tinkering with nice GUI-based visual programming / scripting tools, but the compelling reason for me to get my hands dirty at the command line is the fact that nothing gets in the way.

One of my most enduring love / hate relationships has been with HyperCard / SuperCard. I remember being excited, almost to the point of peeing myself, when I first got wind of HyperCard. My programming days started with BBC BASIC, then Spectrum BASIC, then the woefully under-implemented Commodore 64 BASIC. After that things just got worse and worse and Atari ST BASIC was absolutely useless. I can’t even remember if there was an implementation for the Amiga, but I did try CanDo which was promising but way ahead of its time. As the years passed it got more and more hard work to get to a command line and I kind of missed the direct simplicity of BBC or Spectrum BASIC, which were at least broadly complete implementations that you could actually do stuff with.

Update: I completely forgot about STOS on the ST and AMOS on the Amiga, which were both brilliant.
http://en.wikipedia.org/wiki/STOS_BASIC
http://en.wikipedia.org/wiki/AMOS_(programming_language)

HyperCard was a revelation to me as it was on the desktop, and you could easily create GUI-based applications with it, and it had a pretty decent plain-English programming language. You could actually do stuff with it.
http://en.wikipedia.org/wiki/HyperCard

As desktop computers “improved”, programming became more and more remote from the user, and there was a very frustrating period in the late 80s and early 90s where application software was not mature enough, but programming not accessible enough, to plug all the gaps in our productivity.

Fortunately those days are over.

There were many good things about HyperCard, but it was lacking in some fundamental functions, and for me, they were colour and structured graphics. HyperCard was strictly monochrome and bitmap only, and although Apple eventually did include plugins that supported colour graphics, it was an afterthought and not adequately implemented. Apple neglected HyperCard for years and it is now a minority interest tool. I still use it for programming on old compact Macs as it is one of the few programming tools that will work on machines with no more than 4 Mb RAM.

Silicon Beach SuperCard seemed to be the obvious successor, the so-called “HyperCard on steroids”. Its own language, SuperTalk, was an extended and mostly compatible development of HyperCard’s HyperTalk, and it supported 8 bit colour and script-controllable vector graphics.
http://en.wikipedia.org/wiki/Silicon_Beach_Software

SuperCard, whilst not neglected in the same way, passed from one owner to another for years, developing only gradually. I cannot tell you just how closely related it is to the original, but SuperCard appears to have evolved into something called LiveCode by Runtime Revolution.
http://www.runrev.com/

LiveCode deploys on a number of platforms including Windows, Linux, OS X, iOS and Android, and looks very promising. However, it seems to be lacking one of the fundamental features that I need, and that is to append single images to a movie file. Please correct me if I’m wrong, but I can’t find any mention of it, although I’m still looking into it.

And this is my big frustration when using very-high-level development tools. I tried using Apple Automator and QuickTime Pro player to assemble digital stills into movie files. Again, maybe it’s there but I couldn’t find it without having to operate the menu items in the player, and I really don’t want to go back to the days of using marionette software like Keyquencer (remember that?) or similar to operate programs via their menus. In my experience, automated clicking of buttons and selecting menu items is just not reliable or fast enough.

Adobe Photoshop’s Actions is a very powerful tool but it’s quite slow (although things may well have changed since CS3).

And this is when we get back to Linux, GIMP and ImageMagick. Whilst I have been banging my head against a brick wall for years, looking for the ideal development platform, Linux tools and libraries have been quietly maturing under my nose. I recently looked into using ImageMagick, which can do, well, everything. For the uninitiated, ImageMagick is a “software suite to create, edit, compose, or convert bitmap images” and can also procedurally create images by manipulating graphics or drawing shapes.

There are some very coherent and complete help files, written by Anthony Thyssen, and they seem to go on forever, documenting more and more features, available via command line. And the command line bit is the real killer because it means I can write a program and just call the single function I want, and add it to a Bash script.
http://www.imagemagick.org/Usage/

My own interest is in batch-converting, montaging of multiple images and format conversion of data sets, often comprising tens of thousands of images. I have managed to use gPhoto2 and FFmpeg to assemble the images into movies, and ImageMagick / GIMP will help me to manipulate the images if need be.

More soon…

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.