Category Archives: My Projects

Experiments in video capture

Example Frame From Jurassic ParkI recently reinstalled my Hauppauge Win-TV card in my server box, and have been working a bit at getting my webcam software up and running. But rather than just play with occasional image capture, I was wondering what the possibilities would be for recording live video for later playback. So, I embarked on a bit of experimentation using tidbits of software that I had lying around.

Note: My server is a 1ghz VIA Nehemiah chip, which isn’t fast enough to do software encoding of full video frames, so all experiments were performed at resolutions of 352×288 or 320×240. This is more directly comparable to ordinary VideoCD: watchable, but not archival quality. You can see an example frame on the right, at the size I normally use for video capture. Modern PDA’s can actually play back mpeg4 streams of this quality, so this might be comparable to what you’d get on one of these.

First of all, I installed ffmpeg. It has a video capture mode that works with the FreeBSD brooktree driver, so it seemed like it was a promising start. I ended up with the following script: Continue reading

Fun With Music, via abc2midi

Since discovering that the classic baseball tune Take Me Out To The Ballgame was in the public domain, I decided that I might like to have a version of it that I knew was free to use however I might like to. I found out about the ABC Music Project. These programs were principally used by people researching folk music, but allow you to produce sheet music and playable MIDI files from the same source code. They aren’t entirely intuitive, but they do work. A couple of hours of work and I have the tune as an mp3 file and typeset as a PDF file.

The really cool thing about this is that it allows you to create one common source format for music that can be converted into two useful forms: both MIDI files for performance and sheet music for instruction. Try looking around, there is already quite a bit of music in ABC format.

Fixing Old Motion Picture Film

Thief of BaghdadI’ve been reading papers lately about using image processing techniques to remove artifacts and damage from old motion picture film. Some old films are remarkably pristine, but some, like my copy of Douglas Fairbanks’ 1924 version of Thief of Bagdhad show lots of wear and tear.

I think it will be possible to write an automated system for removing many of these artifacts, so I thought I’d give it a whirl. The first baby step is to be able to read individual frames off the DVD and convert them into a canonical format. Luckily, the ffmpeg project has a pair of libraries which can read a wide variety of video formats and convert them into standard grayscale, RGB or YUV colors spaces. Tonight, I wrote a program which slurps off the first 1000 frames from a DVD .vob file, and saves them out as PGM files (grayscale only, since this film is black and white). You can see a small example on the right, or full frame version here. You can see a couple of artifacts: dust, dirt, and vertical scratches. The exposure of the title slide is also rather
uneven.

This is just a baby step, but a necessary one. My next step is to scan the DVD and determine the scene breaks. I suspect I can do this simply by summing the squared differences between adjacent frames, and splitting the sequence at peaks. Once I have this, then I can begin on a scene by scene processing. I envision a system that will eliminate the film weave, uneven exposures, and vertical scratches. If I get that far, I’ll be very, very proud.

Flame Fractals

First FlameWhile watching the Athletics lose another game (sigh), I dusted off this paper and coded up a quick implementation. It seems to work, although I’m having some problem with the tone mapping bits, and haven’t bothered getting any color into it yet. It’s not really very useful, except perhaps for making backgrounds for your desktop.

Realtime implementations of this are available, especially as screensavers. My favorite is the electric sheep, which provides a never-ending variety of cool looking flame fractals.


World Series Baseball

I was mulling over the mathematics of the World Series in one of my more bored moments, and decided to write some simple Python code to test an idea. The question underlying these graphs is essentially this: given that the probability of Team #1 winning any individual game is a probability p, what is the odds that the team will win the Series? And what is the average duration of the Series?

A few minutes of Python hacking gives the results in nice graphical form (courtesy of gdchart):

Probability of Winning
Length of Series

For some reason, the title along the Y axis of the second graph is screwy, I haven’t been able to figure out why. I’ll play with it later.

There are few surprises here: the probability graph is a sigmoid which begins at 0, goes through 0.5 at x = 0.5, and ramps off at 1.0. Similarly, the duration peaks when teams are evenly matched, somewhere around 5.8 games.

What was this worth? Not much. I just liked to make the graphs.

More Public Domain Images and a Correction

Frog, colorizedJust another example of an image that I scanned from the Dover book and colorized. I kind of like it!

Now, the correction: in reviewing Fishman’s book on the Public Domain, I am reminded that the term “copyright free” is not synonymous with “public domain”. From Fishman, page 3/27,

The words “copyright free” are often used to describe works (particularly photos and clip-art) that are under copyright, copies of which are sold to the public for a set fee rather than under a royalty arrangement.

So it remains to be seen whether these images are in fact in the public domain. These old style woodcuts appear to be of a style which suggests they predate possible copyright protections, but I suppose it’s vaguely possible that they are not public domain.

Till then, enjoy the images under the appropriate use of their “license”. I’ll investigate more, and probably end up writing them to find out what they think their position is.

Addendum: I found this site on Copyright for Collage Artists, which contains good information which seems sound.

Public Domain Images

butterflyI was looking for some clip art that I could use on my website, so last time I was at the bookstore I acquired a copy of Dover’s Old Fashioned Animal Cuts, a book of copyright-free images ready to be scanned. It’s a fairly nice collection of hundreds of black and white images which are copyright free.

They could have just said “public domain”. After all, if a work is not protected by copyright or trademark, it is in the public domain. Curiously, Dover includes the following “license” in the front of this book.

This book belongs to the Dover Clip Art Series. You may use the designs and illustrations for graphics and crafts applications, free and without special permission, provided that you include no more than ten in the same publication or project. (For permission for additional use, please write to Dover Publications, Inc., 31 East 2nd Streen, Mineola, N.Y. 11501.)

However, republication or reproductin of any illustration by any other graphic service whether it be in a book or in any other design resource is strictly prohibited.

FishWhat’s wrong with this? The fact that it is a complete fabrication. If the images themselves do not carry copyrights, they cannot place any restrictions on their use. That’s what public domain means. They can copyright the collection as a whole, keeping you from basically Xeroxing their collection (which is a creative work, requiring the acquisition of images and their arrangement in a catalog format), but they can’t keep you from, say, scanning them all and producing your own derivative work in the form of a catalog of your own.

I’m not trying to bust their chops. They produce a nice $6.95 book which is convenient and good to have, and frankly worth the pittance they charge. But for them to place restrictions on the use of their public domain collections is well beyond any rights they hold to the collection.

Caveat emptor: I’m not a lawyer, and cannot advise you on these, but you can go ahead and read up on the subject. I suggest Steven Fishman’s The Public Domain: How to Find Copyright-Free Writings, Music, Art and More.

Weekly Weigh In

Today’s weigh in saw me give back last week’s loss. Not too surprising given the fact that I have been eating a bit more. A company picnic full of yummy barbecue food probably didn’t help much, but there were plenty of other times when excessive snacking happened. Oh well, I shall try to do better next week.

Weight Loss Graph

An aside: Carmen and I got out of a movie late last night and felt like we needed some kind of dessert. Normally this means either air popped popcorn, watermelon or Skinny Cows, but we were out of all three. I stopped in at Albertson’s to restock.

I decided to give the CarbSmart Ice Cream Sandwiches a try, since they were on sale. Their numbers are 80 calories, 40 from fat, and 1g of dietary fiber. If you compare this to a mint Skinny Cow, you’ll find that the Skinny Cow has 120 calories, but only 20 due to fat and 2g of fiber. Both work out to around two points (the Carbsmart sandwhich has higher fat and lower fiber, which counts against it). So arguably, both are about the same, at least for those of us on the Weight Watchers diet. No reason to prefer one over the other, right?

Wrong. The thing is, the Carbsmart bar is a 2oz sandwhich which amounts to barely more than a mouthful (at least for someone with a big mouth like me). The Skinny Cow is a 4oz sandwhich, literally twice as big.

There you have it: Skinny Cows, just better.

Holy Crap! My scanner works!

coinsI have a Canon LIDE 20 scanner, a super cheap LED flatbed scanner. I figured there was no way that it would possibly be supported under Linux. After all, none of my other scanners ever was, largely because I am so cheap I never buy SCSI scanners. But remarkably, it does work, and right out of the box with Fedora Core 2. I typed scanimage -L and land of mercy, it found my scanner. Then a simple scanimage --resolution 300 --mode Gray | cjpeg > foo.jpg, and voila! It works! A bit of GIMP work, and you can get the image on the right.

I also scanned an image of an ordinary quarter as a test. At 600dpi, considerable detail, some of it nearly microscopic is clearly evident.

Trilobite Fun

TrilobiteI have this old trilobite fossil that I bought from the Discovery Store. I find it kind of neat to have a specimen from 530 million years ago sitting on my desk. I made this picture by plopping the fossil onto the flatbed scanner at work and just scanning it at 300dpi. The original scan was a 2.8megabyte TIFF file, which I processed a bit with GIMP to form the image on the right. Using scanners to make pictures of shallow objects is an idea I’ve talked about before, but this was a nice application.

At home I have a Canon LIDE 20 scanner, which uses an LED light source, but it really doesn’t make very nice pictures (they get fuzzy quickly as the depth falls away from the bed of the scanner), but it was super cheap. It’s okay for doing coins, but pictures of things with deeper focus is not really satisfactory. Try scanning objects on your own scanners and see how they turn out.

The Fun of Radio

Mighty MiteI admit it, I have a ham radio license. I’m KF6KYI, a lowly Tech licensee. I went through a brief phase where I learned alot about radio, but then it kind of fell off for me as I realized that few people were interested in doing the kinds of work with radio that I was. But I did become interested in the world of QRP, or low power operation. What’s cool about low power operation is that many people build their own rigs, and often very inexpensively. The idea of building a $10 transceiver and using it to talk to someone in the neighboring states is interesting to me, and no page that I’ve ever read was more in touch with this notion than HOMEBREW QRP IS GUD 4 UHOMEBEW QRP IS GUD 4 U, now maintained by WB5UDE. Despite the atrocious use of abbreviations, the author shows just how simple it is to assemble a working ham radio station from scratch. Applause!

The schematic on the right is a 500mw transmitter. It’s called the Michigan Mighty Mite, and has a single transistor which you can probably buy for a buck at Radio Shack. It’s amazing what you can do with very little equipment/money/know how.

Somewhere in my workshop I’ve got a kit for the PSK-80 Warbler, which is another super cheap kit ($45), but in line with my technical interests. It uses the super-nifty-keen PSK31 modulation technique, which is a highly noise resistant digital mode. You plug this little transciever onto your laptop and you can type interactively to other PSK31 users. I’ll have to struggle through the Morse exam sometime so I can give this a try.

I was also trying to find my notes of Lowfer or Low Frequency Part 15 broadcasting. Perhaps I’ll give that a try sometime soon.

Weight Watchers Progress

The project that I’ve spent the most time on lately is actually myself. Last December I was having some health difficulties and visited my doctor, who reported that my weight was as high as it had ever been (a staggering 323 lbs, ouch!) and that my cholesterol and blood pressure weren’t looking much better. I decided that I had to do something about it, and started working to improve my diet, exercise more, and since January, join Weight Watchers.

I’m now down over 50lbs since that day in December, and down an even 35 lbs from when I started weight watchers. If I get down into the 230-240 lb range, I’ll probably be a happy camper. Anyway, I decided to try to make a nifty chart showing my weight loss progress, so here it is!

I’m beginning to slow down a bit, but I’m hoping that increasing my exercise will help. Unfortunately I strained a calf muscle pretty badly on my hill, and it still gives me a bit of pain when I exercise, so I am taking it easy for now (although I did do a walk with Carmen yesterday).

For those of you who have wondered about Weight Watchers, it really does help. I recommend them.

Fun with Python and Cryptography

I’m a bit of a classic cryptography nut, and I also have had a lot of fun writing bits of Python code. Python is awfully good at sucking up text files and performing statistics and the like, so I thought I would go ahead and describe some of the fun things I’ve been doing.

I’ve developed code to crack fairly sophisticated ciphers before, including both the Playfair and Enigma machines, but I thought it might be fun to work on a simple python script to crack ordinary substitution ciphers using evolutionary computation. You would probably get better results from using a dictionary based attack, but I thought this would be both simple and fun. Continue reading