Random header image... Refresh for more!

Previously on Crazy Project Weekend…

A Crazy Project Weekend is when I take an extended weekend and dedicate my time to a AAA project:  One that is Achievable, Awesome, and slightly Abnormal.  There are a couple of rules, made up on the spot this instant, guiding the Crazy Project:

  • Work must be done within the limited weekend time frame.  You cannot begin any concrete work prior to the time window, and if you do not complete by the end of the time, you have failed.  You may do some preparation ahead of time, such as feasibility research or acquiring necessary materials, however, nothing should be built and there should be no written plans.  The point is to see what can be done in five days, not what can be done in five days and a couple of hours an evening for three weeks prior to those five days. 
  • It must not be something you would otherwise normally do.  Setting up a website with a blog and a bunch of pictures of the dog doesn’t count.  Cleaning the garage doesn’t count.  It must not be something that anyone would normally do.
  • You have to learn something.  If you know exactly what you’re doing going in, then it’s no fun.  One of the central pieces of the project must involve something you’ve never worked with before.  There must be several moments where you have no idea what in the hell you’re doing and wonder what you’ve gotten yourself into.
  • You must post regular progress updates throughout the weekend, detailing what you’re doing and what you’ve done.  Viewers must be able to get a glimpse of your thought process and understand what you’re going through.  You should talk about initial goals and milestones, obstacles you see on the path to those milestones, and the general approach you plan to take.
  • Reaction from outsiders to your project must be a mix of “Why did you do that?” and “Oh man, that is AWESOME”.
  • It’s fine to have a mental plan going in, to make sure that you’ve appropriately scoped the project so you have a reasonable chance of success, no matter how unreasonable the project itself may be.
  • Continuing the effort from a previous Crazy Project Weekend is acceptable, even though it violates some of the previous rules.

The first Crazy Weekend Project was over Labor Day Weekend, in September 2009.  I decided that it would be a good use of my time to build a robot out of Lego Mindstorms that could play a game of Pong on an unmodified Atari 2600 and win.  Initially, I had planned to make it play a perfect game of Pong, but I didn’t get there.  Full details here:  http://www.mathpirate.net/log/category/crazy-weekend-project-1-pong-robot/

The second Crazy Weekend Project was over Thanksgiving 2009.  It was limited, in that I only dedicated about half the day to the project (The other half being dedicated to XBox 360…).  There were two goals for this project:  Put together a speech recognition system capable of recognizing and responding to a set series of commands, as well as write a system that could identify faces.  Speech recognition came together very quickly, so the bulk of the time was spent trying to make Wesley Crusher disappear from episodes of Star Trek: The Next Generation.  Full details here:  http://www.mathpirate.net/log/category/crazy-weekend-project-2/

This will be my third Crazy Weekend Project.

February 25, 2010   No Comments

Electric Curiosities: Home Video Formats

It’s been a while since I’ve done an entry in the Electric Curiosities series, so let me make up for the absence with RICARDO MONTALBAN!

 1

When it comes to watching movies at home, two acronyms jump to mind immediately:  DVD and VHS.  DVD is morphing into Blu-Ray, and people remember (and laugh at) Beta.  If pressed, most people might even mention those “Big CDs”, called Laserdiscs.  However, we’ve already forgotten about HD-DVD and no one ever knew about 8mm tapes and CED Video Discs.

Let’s explore some of these various home video formats, shall we?

(And yes, I know this is a departure from the video games I normally talk about, but the name is ELECTRIC Curiosities.  Might as well expand the horizons a bit, eh?)

Blu-ray

Blu-ray is the FUTURE.  Bigger, better, hi-def, whatever.  I think you all pretty much know what this is, so I’ll save my typing fingers and just move on.

HD-DVD

HD-DVD was a competitor format to Blu-ray.  It lost.  Oh well.  Moving on… 2

DVD

In the days before DVD, people had to spend hours of their lives painstakingly rewinding video tapes.  This was such a horrible experience that stand-alone tape rewinders were available for sale that would do absolutely nothing but rewind tapes faster than VCRs did.  You’d get charged a fine at rental shops if you failed to rewind before returning the movie.  Forget about the incredible picture quality improvement, forget about the extra content, forget about multiple soundtracks, forget about instant chapter skips, forget about interactivity:  DVD took over because you didn’t have to rewind.  No, really, it was that big a deal.

VHS

I couldn’t figure out what in the hell this thing was supposed to be.

It didn’t fit in my XBox.  It must be broken.  Do I have to break it open or something to get at the movie?  I just don’t understand it.

Beta

Before HD-DVD vs. Blu-ray, there was Beta vs. VHS. 3  It had better picture quality than VHS, but lost mainly due to recording time.  Initially, Beta did only one hour on a tape.  Sony, being arrogant4, decided that people would buy it anyway.  Then the two hour VHS tape came along.  By the time Sony got their act together and increased the recording time, people had already bought VHS VCRs, and because people bought VHS VCRs, rental shops stocked VHS tapes, and because rental shops stocked VHS tapes and not Beta, people bought VHS VCRs.  Beta == FAIL.  Now, while Beta failed in the home video market, it did quite well in the professional market, such as newscasts.  It didn’t really matter that you could only record an hour if you only needed to film fifteen minutes of B-Roll and a five minute interview on location every night.  What mattered there was picture quality.  Plus, Beta tapes were notably smaller than VHS tapes, so they were easier to carry around.

8mm

Even smaller than Beta, 8mm tapes were released in the mid-80’s as a competitor to VHS.  While they proved to be a popular format for camcorders (because they reduced the size of a camcorder from roughly that of a shoulder-mounted rocket launcher to something that could be used comfortably while handheld), 8mm never really took off as a commercial movie format.  It wasn’t any better than VHS quality, and you still had to rewind, what’s more, it cost more than VHS.  Commercially sold 8mm movies were largely limited to creepy hotels and airplanes, largely due to their compact size.  Also, don’t confuse 8mm video tapes with Super8, which was a film format. 

Super 8

Don’t confuse this with 8mm video.  This is film.  A spool of see-through pictures and sprockets.  Film.

Super-8 movies came on one or more reels, roughly 15-20 minutes each.  The full-length version of The Godfather, for instance, came on 11 reels.  This particular film is a “selected scene edition” of Star Trek: The Motion Picture, condensed into a 12 minute run time on a single reel. 5 If you had the right kind of projector, Super-8 movies could have sound, thanks to a magnetic strip on one side of the film.  If you had the wrong kind of projector, you had to re-enact the voices, all Rocky Horror style. 

Laserdisc

Laserdisc was blindingly awesome.  Literally.  You could use its large shiny surface to reflect the light of the sun into the eyes of anyone who insulted the format.  LDs were a foot in diameter, and looked like a record-sized CD.  They offered better picture quality than VHS6 and didn’t have to be rewound.  Unfortunately, you couldn’t record to them and they were much more expensive than VHS.  On top of that, the makers of the Laserdisc, in order to help prevent deep-vein thrombosis in the audience, decided that the viewer would have to flip or change discs at least once during the film, sometimes as much as three times in a two hour movie, depending on the encoding style.  Couch potatoes stuck with VHS, while rich people, exercise freaks, and snobs adopted Laserdisc.  Additionally, Laserdisc found popularity in schools, where the clear freeze-frame capability allowed video slide shows with instant random-access scan to a specific frame.  Laserdiscs also landed in arcades, where the random access video was used for graphically stunning games like Dragon’s Lair, Space Ace, Time Traveler and Mad Dog McCree.  Too bad those all sucked as games.

UMD

So…  I really don’t understand UMD.  It’s more expensive than DVD.  It has a smaller capacity than DVD.  It generally has fewer features than DVD.  It plays on one thing and only one thing, which nobody bought, and that one thing that has a four inch screen.  The library consists mainly of films made between 2000-2005, which no one really wanted to see to begin with.  So, uh, why can I walk into Best Buy and still find a UMD movie section?  It makes no sense to me at all.  It’s like all the stores still have their entire original launch day selection, and they’ve completely forgotten that it’s there.  Sony’s even trying to kill the format for games, which is the only reason for it to exist.  Why hasn’t it died and gone away?  HD-DVD was completely out of stores within about two months of the Blu-ray victory.  Why do UMD movies linger so?

VideoCD

A VideoCD contains MPEG compressed video on a standard CD-ROM.  It came out in the mid-90’s, around the same time as the first CD based game consoles.  Some of them, such as the Philips CD-i and the Amiga CD32, had add-on modules that allowed the console to play VideoCDs.  Imagine that, a game console that could play movies.  The video on a VideoCD was compressed such that it could be played back in a single speed CD drive.  That meant that you could fit about 70-80 minutes of video on a single CD.  That, unfortunately, meant that a movie had to come on at least two discs.  The quality was generally better than VHS, if you didn’t mind the occasional compression artifacts.  Because the video is normal MPEG video, and because the disc is a standard CD-ROM format, PCs have no problem playing VideoCDs.7  Also, although you might not be aware of it, there’s a good chance that your DVD player will happily play VideoCDs, since the format is very similar to that of DVDs.

DIVX

DIVX looks like a DVD.  DIVX uses the same disc format as DVD.  But DIVX is not DVD. 8  You see, when you buy a DVD, you get to watch it the night you buy it.  You get to watch it the next day.  You get to watch it over and over and over until the disc develops stress fractures and disintegrates.  That’s the beauty of buying a movie.  DIVX didn’t see things that way.  The people pushing DIVX (Circuit City and, um…  Circuit City) decided that people would want to pay $5 for the disc9 and be able to watch it for 48 hours.  After that time frame, if you wanted to watch it again, you had to pay again.  Basically, you had to rent movies that you owned.  The target market for this was apparently the people who had enough time to go pick up a movie from the store, but who were too busy to be able to take it back to the rental place when they were done and hated late fees.  If you wanted, you had the option to pay to upgrade the disc for unlimited viewing.  Controlling all of this was a telephone connection to the mothership, where every movie you watched and how often you watched was tracked by the system.  And if the mothership didn’t respond, your grand movie collection was worthless.

Yeah…  That didn’t work out so well for them.  The amazing part is that Circuit City survived for another ten years after this disaster.

You could try to play a DIVX disc in a regular DVD player, but all you’d get is a screen like this:

CED Videodisc

I’ve saved the one that’s probably the most bizarre for last.  I’ve given you movies on CD and movies on record-sized CDs, so why not give you movies on a record-sized record?  Seriously, the CED10  is vinyl and grooved and played back with a contact needle which reads the bumps and dips in a groove.  Like a record, the needle would wear out and need replacing over time.  Also, like a record, the movies would occassionally skip.  There are no known instances of early rappers “Scratching” a Videodisc, but you have to admit that the thought is awesome. 11  Video quality was roughly on par with VHS, although CED discs could only hold about an hour per side.  However, they were initially cheaper than VHS tapes and enjoyed limited popularity among those with lower income or who were just cheap.

While records spun at 33 1/3 RPM, CED discs went at 450 RPM.  That means it’s spinning around 7.5 times a second.  NTSC Television signals are 60 frames per second 12, which means that each rotation showed eight frames.  If you look at the closeup of a CED, you can actually SEE the frame spacing. 

The disc is divided into eight wedge-shaped segments.  Each segment is a frame, and the divider is the Vertical Blanking Interval.  If you look really closely, you’ll see narrow lines within each segment.  Those are individual scanlines separated by the Horizontal Blanking Interval.  Think about that for a second:  YOU CAN SEE THE MOVIE ON THE DISC. 13

CEDs were designed so that they never had to be handled directly, since fingerprints and dirt could screw up the picture or gum up the needle.  In fact, CEDs were designed so that you typically never even saw the disc.  Movies came in hard plastic caddies. The case was inserted into the player, and when it was removed, the disc stayed behind.  An hour later, when you had to flip the movie over, you put the case back in, the disc and plastic ring locked back into place, you pulled the caddy back out, turned it over, then stuck it back in.  In order to actually see the disc, you had to unlock the inner ring with screwdriver and pull it out.

Obviously, being vinyl, you couldn’t record on it.  But you also couldn’t fast forward, rewind, or pause and still see a picture. The needle made physical contact with the disc.  If you fast forwarded or rewound,  the needle had to be lifted in order to prevent damage, since the action was done not by speeding up the disc, but by moving the needle in or out, just like going to the third song on an ordinary record.  As for pausing, the needle also had to be lifted.  The disc was one continuous groove.  If you left the needle on the disc, it would track with the groove, so it would play the movie.  If you held the needle in place and prevented it from tracking, it would have to jump the groove wall, probably damaging both the needle and the disc.  At the time, the electronics required for keeping a frame in some kind of memory so that the video could be paused and still show an image were insanely expensive. 14

One of the most interesting tidbits about the Video Disc is the fact that there were plans to produce an add-on for the ColecoVision which could drive a CED player for games.  Imagine how that could have changed EVERYTHING about the video game industry.  Affordable, random access, full motion video games in your living room, in 1983.  Sure, there would have been a lot of Mad Dog McCrap, but I have one word for you:  Myst.  In 1983.  It wouldn’t have been a computer-generated photo-realistic world, but there would have been games that were just as immersive and beautiful.  We would have had the CD-ROM revolution ten years earlier.  In that world, would Super Mario Bros. even have existed?  How could low-res blocky 16 color graphics compete?

That concludes the tour for today.  For scale comparison, here’s a couple of shots with the different formats, all happily coexisting.

So now, before you go and pirate a movie off the IntarWebZ, think for a minute about what you’re missing.  Sure, you may be able to get a shiny HD copy of the latest movie in a matter of minutes with just a few clicks, but you don’t get a badass three inch tall picture of Ricardo Montalban on the case!

 15

  1. KHHHHHHHHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAANNNNNNNNNNNNN!!!! []
  2. It failed so miserably, I couldn’t even find any Star Trek releases on the format, other than The Original Series, which would have been unsuitable for this post. []
  3. Actually, even after HD-DVD vs. Blu-ray, there’s still Beta vs. VHS, because HD-DVD was such a failure, it couldn’t even beat Beta in the “Biggest Loser Format” competition. []
  4. See PS3’s $600 launch price tag… []
  5. Interestingly enough, this version is the only one that’s actually watchable… []
  6. And some will say, better than DVD… []
  7. Or borrowing the MPEG files for other purposes… []
  8. DIVX is also not related to the Divx codec, except in name, which is a sarcastic reference to this format. []
  9. Granted, DVDs were $30+ at the time, so that was a good cheap price. []
  10. Capacitance Electronic Disc, if that matters. []
  11. Actually, though, although you probably could “scratch” a CED, it’s likely that it would simply produce a strange shifting color display as the scanning beam displays the same color for a long time, and, on some TVs, a loss of vertical hold, causing the screen to flip. []
  12. It’s slightly more complicated than that.  NTSC signals typically contain 30 distinct images a second, but each image is shown on two subsequent scans.  That’s why NTSC is typically said to be 30 fps, even though it’s really refreshing the screen 60 times a second.  Read up on Atari 2600 programming if you really want to gain an appreciation of how TV signals work. []
  13. Actually, you can see the same thing on a CAV Laserdisc even more clearly.  It has to be a CAV disc, though.  CLV discs don’t have the same nicely visible alignment.  With a CAV Laserdisc, you can see the VBI and HBIs for two frames per rotation. []
  14. VHS/Beta did it by simply rescanning the same frame over and over.  Most Laserdisc players only had a pause feature on the CAV style discs, because the physical layout of the frames on the disc allowed the laser to remain stationary and simply scan the same frame over and over and over.  CLV discs couldn’t be paused because of the variable frame alignment. []
  15. KHHHHHHHHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAANNNNNNNNNNNNN!!!! []

February 18, 2010   No Comments

LCARS: Little Crusher Automated Removal System

Here’s the video:

http://www.mathpirate.net/hold/LCARS1.wmv

This is a scene from the Next Generation episode Journey’s End.  The first run is simply the result with Wesley Crusher blacked out.  The second part displays the faces that are recognized.  There are occasional blips (Data gets blacked out in several frames, Wesley’s ear gets “recognized” a few times), but overall, not too shabby for something thrown together in a few days with no virtually no tuning of the system being done.  The reason he’s not blacked out at the end is likely due to the decision to expand the minimum face size to 50×50.  If the face size were smaller, it likely would have detected and blocked that part, as well.

November 29, 2009   No Comments

Inpainting

RemovalInProgress

With this, I tried a technique called “Inpainting”, where you give it a mask of the damaged area, and the software will remove the damage.

November 29, 2009   No Comments

Circular Logic

I tried running it on a different episode and the results were…  A bit different.

STTNGFail2

STTNGFail1

I guess the high success rate was due to finding the training images again.  Oh well, at least it did that right.

And this wasn’t a complete loss, JeanLucPicard was identified correctly most of the time!  And some of the other characters were properly identified some of the time.

I also took a look at the distances for each match.  You see, the match is actually a 2500 dimensional distance calculation between two images.  I was hoping to use this distance to weed out false matches, unfortunately, there wasn’t really that much of a separation between correct and incorrect matches.

At any rate, all that is just tweaking the system.

November 29, 2009   No Comments

Visualization Activated

Images in action:

STTNGFaces1

Target Acquired

STTNGFaces2

Multiple hits.  Note that it doesn’t see Geordi…  I think the face detector relies heavily on the eyes, so his VISOR is confusing it.

STTNGFaces3

It can even detect redshirts!

November 28, 2009   No Comments

It Works!

IT WORKS!

HOLY CRAP IT ACTUALLY WORKS!

I trained it on a set of about half of the images, because it takes a long time to train.  Then I ran it on the video and it was actually returning the right person most of the time.  I’m actually shocked that it’s working so well, especially seeing that this is the first time I’ve had the recognition part actually compiling and running.  No real tweaking necessary.  The problems I’ve been having have all been with calling the functions and simply using the library, it’s not that the software was doing what I told it to do and it all came out wrong.

Looking at this trace, you can even get a sense of the cuts in the scene:

Recognized: JeanLucPicard
Recognized: DeannaTroi
Recognized: JeanLucPicard
Recognized: DeannaTroi
Recognized: DeannaTroi
Recognized: JeanLucPicard
Recognized: DeannaTroi
Recognized: Anthwarta
Recognized: Anthwarta
Recognized: Anthwarta
Recognized: Anthwarta
Recognized: Anthwarta
Recognized: Anthwarta
Recognized: Anthwarta
Recognized: DeannaTroi
Recognized: DeannaTroi
Recognized: DeannaTroi
Recognized: JeanLucPicard
Recognized: JeanLucPicard
Recognized: DeannaTroi
Recognized: JeanLucPicard
Recognized: DeannaTroi
Recognized: DeannaTroi
Recognized: JeanLucPicard
Recognized: DeannaTroi
Recognized: DeannaTroi
Recognized: DeannaTroi
Recognized: DeannaTroi
Recognized: JeanLucPicard
Recognized: DeannaTroi
Recognized: JeanLucPicard
Recognized: Anthwarta
Recognized: Anthwarta
Recognized: Anthwarta
Recognized: Anthwarta

Of course, right now, it’s only working on the positive cases.  When it knows someone, it knows them.  When it doesn’t know someone, it randomly guesses about who it is.

Now, something interesting about that…  I haven’t trained the system on Wesley yet.  He’s down in the Ws and the images I trained with were alphabetical.  However, in the scenes with him, he’s fairly regularly identified as “JeanLucPicard”.

Gotta wonder if the Doctor and the Captain have something they need to talk to him about…

Now I just have to label the faces on the screen, since screenshots are better than random text.

November 28, 2009   No Comments

Admirial Nechayev Will Eat Your Soul

AdmiralNechayevWillEatYourSoul

Creepy.

And a sign that this isn’t going to work so well.  I think at this phase, you’re supposed to see something that, well, kinda looks more like a face.

It’s 4 PM and this is all I have so far.  This sucks.

November 28, 2009   No Comments

That Was Easy

Turns out the version of the 1.1pre1a OpenCvSharp library that I pulled down as part of the source was newer than the one I got in September, and it already had the CalcEigenObjects function in it.  So, I didn’t have to go all Kobayashi Maru on the thing and produce a hacked-up Frankenassembly after all.  (Which, in a way, is somewhat disappointing…)

And remarkably enough, I run the old stuff and the new stuff and it doesn’t die left and right.

Of course, I have no idea what it’s doing, but using a lot of CPU and not crashing makes it seem like it’s doing something right.  At least it’s a step in the right direction.

November 27, 2009   No Comments

No-Win Situation

I went back to the code I wrote yesterday that was working with 1.1pre1a yesterday and now it’s giving access violations.  So something in 2.0 is very unhappy.

I am very unhappy, too.

Let’s see…  I can go back to 1.1pre1a and not be able to use the functions I need to recognize faces, or I can keep on 2.0 and do NOTHING AT ALL.

I get the sense that, much like the Higgs Boson and the LHC, my program is sending itself back in time in order to prevent itself from being written, because the consequences of having a program that can automatically wipe out Wesley Crusher from TNG episodes are too disastrous to allow to happen.

However, there is a third path, a way to solve this no-win situation.  In order to fix the first bug I ran into with 2.0, the P/Invoke thing, I had to get the source for OpenCVSharp.  At the time, I was slightly annoyed that it was pulling down both the 2.0 and 1.1pre1a branches from the repo.  However, now that I have the source to 1.1pre1a and the source to 2.0, why not pull the missing code out of the 2.0 branch, stick it in the 1.1pre1a branch, and go from there?

You can always find a solution by reprogramming the problem.

November 27, 2009   No Comments