Monday, August 31, 2009

XNA, GSP and Me

My new classes have started for Session B this semester. My GSP-360, Applied Development Project is shaping up to be interesting. It's designed more to be a modding class, but I don't want to use Torque (suggested) or mod a different game. So I proposed a XNA project. I managed to find 3 other people willing to give it a shot, with me as leader.

Hopefully we can pull it off. I tried to recruit capable programmers, but thus far they have been pretty unresponsive beyond expressing interest. Though, it is only day 2 of class. I'm just uber excited. Given that, I've already jumped into some XNA projects. Hopefully I'll have something worth sharing in a day or so.


Wednesday, August 19, 2009

Quickcam Pro Webcam Installed without Crappy Logitech Software

My computer at work went bust (thanks to an IT push) and I needed to have an admin reinstall the Logitech Quickcam Pro drivers. Unfortunately, the little driver for the camera comes with a 85 Mb download including some intrusive software that is always running. Why do these little peripherals have this crap?

Anyway, I was determined not to install this crap again so I scoured for other drivers without much luck. So I tried opening the 85 Mb EXE (downloaded from Logitech) with WinZip and what do you know, its an archive. So I extracted it, plugged in my camera and navigated the hardware wizard to the extracted drivers directory and now my Quickcam Pro 4000 works without their "software".


Monday, August 17, 2009

Face Detection ala OpenCV


I found this cool tool called OpenCV, which stands for Open source Computer Vision. Its a library for programming computer aided vision stuff, such as with a web cam. I got the face detection algorithms working and as you can see, we're having a little fun with it.

The little red circle on my forehead is the brightest spot in the image. The software will detect any number of faces, circling each. I'm going to make a "temperature" plot based off a target color to help diagnose finding a green laser dot.

I know that although this may sound simple, I'm going to have a lot of problems with color and balance considering the lighting situations I have.


Saturday, August 15, 2009

A Nearest Color Algorithm

I've been developing this software at work to take an image from a video stream (a webcam in this case) and detect if a green laser dot is present. After spending most of my day getting a project to compile and a program to recognize my webcam as a stream, and being distracted by numerous other projects and co-workers, I just wasn't at the top of my algorithm development game to detect the green dot. Combine that with office lighting and you know my dilemma (fluorescent lighting is often green tinted and throws off a white balance.)

I start by stepping through each pixel in the source and check its color. If you take the pixel's colors from each channel and find the average you've essentially got a gray scale value. This doesn't work so well since some shiny metal might throw off the detection (like a ring). If I wanted to find the brightest spot, this is a good approach, but I needed to emphasize the green. At first I added a weight to the green channel by simply doubling it. So now the average is calculated as (R+G+G+B)/4, counting the green channel twice. This was better, but also prone to problems.

At the end of the day I had a basic project setup and working with some hit or miss detection. I had invested over an hour into multiple approaches and although my algorithms for color matching were working somewhat, and I knew there had to be a better approach.

What dawned on me later was something I should have noted much earlier. I know that the RGB color concept is essentially a three dimensional array, but since it is color I'm used to thinking of it two dimensionally like you see in an image editing program. Once I visualized it as a 3D space, a big cube made of blocks so to speak, I knew my answer.

You know the shortest route from A to B is a straight line right. This is easy to calculate in 2D using the Pythagorean Theorem as you probably recognize:

a² + b² = c²

This also applies in 3D space, which is exactly what RGB color is. An RGB value is a point in a 3D space. The Theorem applies like this:

a² + b² + c² = d²

The obvious solution was in front of me but I didn't see it. Euclidean distance would give me exactly what I needed. I needed to treat the color difference as a distance.

r² + g² + b² = d²

For instance, say I wanted to find the closest pixel in the supplied source to a target color RGB 128, 255, 128. I check pixels against my target color by finding their channel distance. So imagine I have a black pixel of 0, 0, 0. My distance is calculated as:

r = pixel_color - target_color = 0 - 128 = -128
g = pixel_color - target_color = 0 - 255 = -255
b = pixel_color - target_color = 0 - 128 = -128

d = sqrt(r² + g² + b²) = 312.7

What if I have a pixel with color 0, 0 255, or a pixel with color 0, 255, 0. Which one is closer to my target? If I calculate the average, they are the same. But by distance, the green pixel is closer to my desired.


Monday, August 10, 2009

Your Controls a-Splode


Splosion Man, a XBox Live Arcade game that is pretty fun (especially according to my 6 year old) has a lot of humor. For instance, this menu allows you to remap the button controls. However, your choices are limited to the following: SPLODE. As you can see, I've remapped each of the buttons to the available options.

This is just the trail version, so perhaps they actually do do more, but this made me laugh non the less.


Guerrilla Self-Esteem Promotion

Recently, in my neighborhood, the roads re-surfaced with tar, then with small loose gravel. This sign used to say "Loose Gravel" but some awesome, yet unknown, neighbor decided to change them into something much better. This is the "Be Happy" version, the other 3 signs were changed similarly, with 2 others saying "Laugh Often!"

It was a good day.



Tuesday, August 4, 2009

PdaNet for Android Doesn't Work For Me

I follow a number of tech blogs, game blogs, fun blogs and serious code blogs, and then some, and the best time for me to do it is at work. Granted, much of it is personal interest, but it turns out my work is often very related. This was working fine and although they block everything cool or interesting on the main network, they didn't on the guest network so I was free to roam via my laptop. Until Monday that is. They have now installed the worlds most ridiculous, draconian, big brother web blocking scheme imaginable to guests. Game is a four letter word. Storage sites like imageShack are blocked, no questions asked. Absolutely no streaming anything, including YouTube, Viemo, and a sad consequence is the Ted presentations. This from a company that is shouting (though its up-to-the-era internal message systems, such as that paper newsletter we can pick up near the door or get in our mail box) how innovative and cutting edge we are.

Damn it pisses me off. The internets is video and they block it. The internets is streaming and they block it. If I try to search for something graphics or programming related, it often ends up blocked, flagged as game or hacking or forums. Forums and IRC and newsgroups are off limits, good thing this isn't where the answers to common questions are easily found. The company is digging themselves a grave IMO; a shallow grave of cold old technology to cuddle up with and wither away as the world passes them by and their employees dream of greener pastures.

Anyway. For mostly personal reasons I was trying to find a way to bypass their guest internets connection all together so I looked to my G1 phone and found an app called PdaNet. It basically tethers a Smart Phone to a PC via USB and the phone acts as a modem, using the 3G (or Edge I guess) network to access the internets. The install is one of the best I've seen and was painless. The software is easy to use and has user controls where they should be (it only runs if you ask it to). But the problem is that although I'm able to see the internets unfiltered, much of it just doesn't load or times out. Gmail and Reader fail to load, as did a few others I tried. Other sites opened fine, but it was of little consequence since my main hope was to bypass the filtering so I can read the blogs I like as they are intended, with images and video.

One of my objectives at work is to stay up to date on relevant technology. I can't do that at work now. A project I'll soon be working on will incorporate interactive technology, which is impossible to research at work because of the blocking. To me, this is basically guilty until proven innocent shit that is going to hurt them more than help.

BTW, if you want to e-mail me at work, don't put swears in the e-mail because I won't get it. That's right, they filter my e-mail and if it has a naughty word in it, they swat it down.