Twists and Turns of The Image Time Comparator

In the course of creating the Image Time Comparator (now offline), I ran into a few hitches. Surprisingly, the parts that I thought would be the hardest to do ended up being the easiest (though, not entirely easy). I had a vision for a website that was an “interactive time-lapse” to compare progress on a construction project with different points in the past. Here are a few of the bumps along the way:

  • I did a lot of research into storing images in a MySQL database with a timestamp, but realized that it’s not a common practice. In a sense, a folder of files is a database, so I decided to use the files names to identify the time the photos were taken.
  • I’ve been using the Unix command line more and more lately and I’ve always been interested in shell scripting. This project seemed like the right one to take the plunge. Shell scripting is an incredibly powerful tool, but it doesn’t have the neatness and readability of languages like C, Java, or Python. Getting the shell script to copy a particular file in a folder on the server with a file name that matched a particular timestamp was a bit of an ordeal. But the best part is that using the CLI of the shell made it easy to see how each statement would be evaluated, so I could try out lots of different things as I was writing the script.
  • I also had hardware issues. I had an old firewire iSight camera that I wanted use, connected directly to the server. I found a binary executable for saving photos via the command line. It would work perfectly for maybe eight hours, and then would crash, leaving the iSight locked from being used. The crontab would keep trying to execute the binary, generating an error about the camera (and filling up by Unix mailbox with error messages). I did some research and found that there’s a very slight memory leak in the binary. Every time it executes and terminates, it doesn’t give back 100% of the memory it was given by the system. Meaning that executing it every minute for hours on end would eventually fill up the memory, making it impossible to take another photo, crashing the application. I decided to dump this binary and checked out a wireless IP cam from the ER. All I had to do was change the shell script to use wget to pull the JPG image from the IP camera instead of executing the binary.
  • I thought it would be very difficult, time consuming, and out of my programming skills to create a script to generate the time-lapse videos, but I decided to give it a shot anyway. I remembered that the popular command line encoder ffmpeg had the ability to string together image sequences into video files. I tried it out a few times on a batch of test files and it seemed to work well. The hardest part was copying over the timestamped files in the right order to the a work directory and renaming them sequentially so that ffmpeg could process them. I was especially proud of the work I did on that shell script.
  • The absolute hardest part was the one that I didn’t give much thought to in the beginning: HTML/CSS/Javascript. I had a particular vision for how I wanted the site to look and feel but only a rough idea of how to make it happen. It took relentless Google searching and code copying to get it close to what I wanted. Getting the image to scale up to the size of the browser window and center was an ordeal, as was changing the image opacity based on mouse position. In the end, I never got it working in Firefox, but I did gain a new appreciation for what web designers are up against.

Overall, I really liked working on this project. I dove into something I didn’t know much about (shell scripting) and managed to get it working the way I wanted. I also enjoyed combining many different technologies, languages and techniques to create something interesting. If I were to continue this project, I would work on fixing the HTML/CSS to make it work better and making it compatible with other browsers.

Comments are closed.