Monday, August 22, 2016

Dr. Eightlegs or: How I Learned to Stop Worrying And Love Arachnids

As a child, spiders were the thing of nightmares to me.  Maybe it's that primitive instinct that developed when we were cavemen telling me that one bite would spell my doom, or maybe it's just the fact that I don't like 8 small legs crawling on my face, but until a few years ago I was paralyzed by the sight of one.  That was until about 2 years ago when I took the time to learn about some of the spider's in Arkansas, and overcome my fears by humanizing them.

This spider, that is currently living in my garage, is called a Cellar Spider.  I've decided to name this one Ochos Locos.  This guy may be able to bite, but he can't really hurt you, in fact he should be your best friend.

Instead of hurting you, Ochos Locos here hurts things that can hurt you.  Cellar Spiders are natural predators to Black Widows, Brown Recluses, and Hobo Spiders.  Not only that, but spiders know how to party.  When threatened Ochos Locos will start vibrating around his web and become a blur.  That's right, with his last breath he plans on dancing (though if they vibrate for too long they will run away).

Of course I don't let any spiders set up camp in my room (for fear of one crawling on my face while I sleep, and inadvertently causing me to punch myself in the face), I let them hang around the garage and in some corners around the house to get rid of the aforementioned venomous spiders, as well as other insects and pests I'd rather not have in here.

You may be asking yourself, why not just get some bug bombs and kill them all?  Well, poison will work for a while, but at some point the spiders are going to come back.  One of the reasons why I don't really see many venomous spiders in my house right now is because of the higher proportion of Cellar Spider to venomous spiders, but after a bug bomb that proportion would be reset.  I would see even more venomous spiders because without a predator, they would find it much easier to "live long and prosper".

With this in mind I've let my friendly neighborhood Cellar Spiders live unmolested, and whenever I find one in the house, I relocate it outside.  If I find a spider that has been doing its job well (killing things I don't want in the house, and not coming into the house) then they I sometimes name them, and that's how Ochos Locos came to be.

Hopefully now you'll think a second before you smash the next spider you find, and potentially name it, and if you want to learn more about your newest spider friend, check out the Wikipedia Article!

Monday, August 15, 2016

Is it there?

My mom, always grabs her mail, and she always puts it in the same place, but sometimes she forgets to mention it to me.  On occasion, when a piece of mail gets around my mail forwarding, then I'd like to know it exists.  So the last time I visited home I set up a webcam connected to my mom's computer, positioned directly above her mail spot.  From there all that was left was to set up a simple Python script to check to see if there is mail there.

I wanted something that works, and not the most complicated solution.  Grabbing the picture wasn't too hard, I tried a few methods I found online, but couldn't get one to work (this time I'm programming on Windows instead of Linux, so I may have had some issues there), but I ended up finding VideoCapture and with a few lines of code I got it working.

From there I used Pillow to scale down the image to a single pixel(think of taking the average of all the colors of an image).  This pixel is represented by a series of three numbers between 0 and 255 representing its RGB values.  For example white is (255,255,255), black is (0,0,0), blue is (0,0,255), etc. 

Now I just needed to compare that color to a stored color. I've worked with colors in Python before, and if you're thinking of the doing something with colors I would suggest using the colormath package.  Here I went with the quick and dirty and just calculated the Euclidean Distance between the two colors: d = sqrt((a1-b1)2+(a2-b2)2+(a3-b3)2).  For example the distance between lime green (34,255,0) and pink (255, 204, 229) is about 322.

If the distance (d) between the two colors exceeds a predetermined threshold, then the script sends an email to me with the original picture, and I know to bring it up in our next talk!

If you want to take a look at the code, take a look at it on my Github.