Quantcast OffBeatMammal | Searching for monkeys in Cyberspace

OffBeatMammal

Searching for monkeys in Cyberspace

Webcams and the command line

clock December 31, 2008 13:26 by author offbeatmammal

After my initial playing with a webcam and weather related time lapse I got a second hand wireless webcam (a Linksys WVC54GC) to play with. As a package it's really easy to set up and connect to the camera and stream video either using their supplied app or Windows Media player. But no use for getting snapshots as user controlled intervals and putting timestamp overlays on them etc.

That left me with a couple of choices:

  • Buy an application to do it (but frankly after looking at some of the options I decided they didn't offer much value - when the software costs more than the camera I expect more from them!)
  • Build my own.

Now, a few years ago when I was developing code on a daily basis that would possibly have been the easiest.... whip up something to connect to the stream, grab a frame, overlay the timestamp and FTP it to the destination.

Today I'm lazier, and anyway the bits I need to do this are all available for free - I just need to tie them together with the command line and they set up a scheduled task to make them run.

Grabbing the stream

The first challenge was connecting to the stream and grabbing a jpg snapshot that I could work with.

Using MPlayer grabbing the frame didn't turn out to be too much of a challenge. It allows you to attach to a streaming video and pull a number of frame to save as a JPEG

mplayer.exe http://{userid}l:{password}@{camera_ip}/img/video.asf -frames 1 -vo jpeg:quality=100:maxfiles=1

Every time this runs it connects to the WiFi Camera video stream and grabs a single, high quality, jpg image (by default saved as 00000001.jpg each time - thanks to the maxfiles parameter)

I used this version of MPlayer built for Windows as it installs and updates easily.

Annotating the image

The next challenge was adding the timestamp to the image to give it some context. This actually gave me two challenges - adding the timestamp and formatting the date correctly from a command line script.

The first was solved with the RunNow.vbs script which allows you to define a number of environment variables for a command line script. I needed to add my own additional environment variable so don't forget to add this to the script

'MonthName
objEnv("MN") = MonthName(Month(dNow))

Next of course was the challenge of actually updating the image itself. For that I turned to ImageMagick a tool I've used before to add text and effects to images. This gives you a number of options for adding a caption to an image.

convert -background "#00000080" -fill white label:"%DOWN% %MN% %Day%, %Year% @ %Hour%:%Minute%:%Second%" miff:- | composite -gravity south -geometry +0+3 - 00000001.jpg image.jpg

This rather scary line takes the source image 00000001.jpg (created from Mplayer) and adds a label using the parameters to position where I want it. The variables %DOWN% etc are all supplied by running this via the RunNow script.

Uploading the image

When the image was composited I wanted to upload it to the Weather Underground site.

Windows comes with a built in command line FTP client, but the Weather Underground server wanted a passive connection which the supplied client doesn't support so I used the free version of MoveIt from Ipswitch - a secure FTP command line client that is a 'drop in' replacement for the existing client.

All I needed to do was create a parameter file to control the FTP script (I saved the script as wificam.ftp)

open webcam.wunderground.com
{username}
{password}
passive
type binary
put image.jpg image.jpg
bye

and call that from the command line

ftps -s:wificam.ftp

Automating execution

Now I had the pieces it was simple enough to create a Scheduled Task that runs every 10 minutes and executes

RunNow.vbs wificam.cmd

the wificam.cmd script contains the call to Mplayer to grab the frame, the call to ImageMagick to add the caption and the call to MoveIt to use FTP to upload the new image.

The results

Every ten minutes the webcam should upload a new image to Weather Underground here, and they create a stop motion view (last 24 hours below).

 

A quick note on the WVC54GC: While it's an okay camera for the job I can't recommend it. The Linksys software is pretty horrible and the specs on the camera are at the lower end of the spectrum - small image size/resolution and really bad low light performance. I know they have better cameras now so look to spend a few extra bucks.



Snowpocalypse 2008 - 10 days in 100 seconds

clock December 29, 2008 11:15 by author offbeatmammal

After my last little experiment creating the stop motion weather watch I wanted to put one together to cover the whole of "Snowpocalypse 2008" as the White Christmas here in Seattle has been tagged.

I used the same tools as before... the webcam had been happily snapping away once a minute and storing the images on the Windows Home Server so I had the source material, but the biggest challenge was to get the 15,000 images displayed quickly enough to be interesting but not so jerky as to be un-watchable. I won't say 8 years working with some very smart TV production teams has actually rubbed off but after some fiddling around the idea of 10 days in 100 seconds seemed to work, so here for your pleasure:

To generate this I took images 5 minutes apart and created an uncompressed 30FPS AVI. The resulting AVI was almost 4GB which obviously isn't practical for streaming on the web (and bigger than the 105MB per file limit for free accounts on Live Streaming!) so I turned to another tool - Windows Media Encoder - to convert the file to a WMV at DVD quality which took me down to 25MB (quite a difference, but remember the AVI was uncompressed and the WMV was a two pass, variable bit-rate encode so heavily optimized).

As it turned out I ended up 4 seconds short of the full 100, but please permit me some artistic license (I should had added a credit roll!)

All this messing about looking at the weather has got me wondering more about what patterns are really like here in the Pacific Northwest so as well as becoming a regular reader of Cliff Mass' musings on the weather Rhiannon and I have ordered our own weatherstation to put in the garden (and started sharing images at Weather Underground as well as the Webcam page here in advance of the hardware arriving!)



Snow days and life at Microsoft

clock December 18, 2008 12:13 by author offbeatmammal

20 years ago when I started working a snow day would have meant the world grinds to a halt.

Today thanks to the wonders of the electronic office I still have access to most of the corporate resources I need to be productive and I don't have to leave home... which is a good thing given the weather!

Thanks to the weather over the last few days a bunch of meetings got canceled I had a chance to catch up on some reading and play with some things...

It's times like this that remind me just what the reach of the Microsoft eco-system is. I'm not talking about the fact I can work from home but the range of tools and technologies that enable pretty much anything you want.

The video above was created in the following way

Apart from the webcam and the Home Server everything is free software. It might not be the most elegant solution but I found all the bits and got it up and running (thanks to Live Search) in about half an hour.

I think folks too often just see Microsoft as a big monolith (even some people who work there!) but it's moments like this, and sites like Microspotting and View<myWorld> and of course some of the more pragmatic 'softees that remind us there's a lot more hidden away both internally and from folks building cool stuff in the community.



Thumbtack - organize the Internet how you want it

clock December 11, 2008 12:24 by author offbeatmammal

Thumbtack There's a lot of stuff on the web, and managing it can be a real pain.

Thumbtack is an easy way to save links, photos, and anything else you can find on bunch of different Web sites to a single place.  Grab the stuff you want, put it into a Thumbtack collection, then get to it from anywhere you can get online. 

You can share a collection with your friends, or just keep it for yourself. It’s way easier than sending a bunch of links in an e-mail, and even easier than setting lots of favorites in your browser.

It works with both Firefox and IE and with both bookmarklet and accelerator support it's really easy to set up and get going.

If you've ever used something like Del.icio.us to collect bookmarks to things on the web you'll appreciate how easy it is to use - and the fact you can actually include snippets of the content, not just a link to the page makes it so much more useful.

Once you collect the information there are gadgets that you can run which (for instance) can automatically parse out addresses and create links to a map so you can see where they are - useful if you're planning places to visit on a vacation, or looking at apartments to rent and want to share the list with your partner.



Twitter - a command line for the web?

clock December 10, 2008 15:38 by author offbeatmammal

Twitter - the Command Prompt for the Internet Back before graphical user interfaces on PCs and the rise of Web 2.0 and the Rich Internet Application you could tell a power user by their mastery of the command line.

It may have been typing ls in a Unix shell or dir at a DOS prompt but these guys knew how to get things done in the leanest, most efficient way. No redundant mouse clicks, no waiting for the translucency animation to rotate your menu options into view. Bang! and move on to the next thing.

Part of the beauty of Twitter is that it goes back to those days of terse interaction and great power.

When it started it was just a simple way to display your status and post messages to your friends (publicly with @ and privately with "d {username}") but it's started to become a lot more.

My first discovery was that I could pipe things to twitter - so I didn't have to do anything to publicize a new blog post but automatically pull from the sites RSS feed to twitter. I use twitterfeed for that.

Then I discovered there were other robots out there that I could send messages to and have things happen. Sandy (sadly now closed down) was an ever helpful personal assistant, gtFtr tracks my exercise stats, Kvetch lets me vent and my most recent discovery is TrackThis which lets me get updates on any FedEx, UPS, USPS or DHL package I have in transit just by sending them a message with the tracking number.

Twitter is also reducing the amount of time I spend in email, IMing and blogging. Rather than clutter up my inbox with one line emails I can use Twitter. I can use Twitter when I don't want to be distracted by the constant ping of Messenger. Rather than try and turn a 2 line blog post into something interesting I can tweet it. if I can't express myself in 140 characters then maybe I need to think more about the post.

In the same way that the command prompt made you more productive if you were willing to learn a few tricks (such as idiosyncratic syntax) Twitter is filling that space in the interconnected internet world... and it's allowing me to do it from everywhere - at my desk, on any web enabled PC or via my phone - it's bringing consistency of experience and incremental benefit to learning those tricks.

So how do you use Twitter as the command prompt for Web 2.0?



World AIDS Day

clock December 1, 2008 09:52 by author offbeatmammal

HIV/AIDS has been a global epidemic for more than 27 years. Most of today's youth have never known a world without it. The U.S. Centers for Disease Control and Prevention recently published national HIV incidence (new infections) that showed much higher numbers that previous estimates. The time is now. Together, we can prevent the spread of this pandemic – through awareness, care, prevention, education and research.

“HIV/AIDS has now become a pandemic that has literally put the world at risk, affecting diverse populations in different ways”. –Dr. Nora Volkow, NIDA Director
 

On December 1st, individuals and organizations will recognize World AIDS Day. This year’s theme is leadership – from all sectors, including government, but also leaders among individuals and families, communities, non-profits and other organizations. The question is not should you participate, but how can you?

If you want more information visit the Bloggers Unite Participation page or AIDS.gov or NIDA. If you're a blogger visit Bloggers Unite and see how you can spread the word.



The girl effect

clock November 26, 2008 10:30 by author offbeatmammal

A while ago I volunteered for a couple of days at the World Vision AIDS Experience. It's an eye opening look at how poverty and disease are threatening the future of the developing world, and how we can make a difference.

World Vision are not alone in seeing the problem, but it's interesting how many of the solutions revolve around the role of women in that environment.

With World AIDS day and Thanksgiving fast approaching, stop for a moment and consider the girl effect. What can you do to help fix the problem?

If you don't have time or money to contribute, visit the Girl Effect site and help spread the word, or put your computer to use to help crunch the numbers when you're not using it


Upgrading the Zune installation

clock November 24, 2008 20:57 by author offbeatmammal

I've been really pleased with the Zune integration in the Mustang so far. The sound quality is great and it's really reliable (being able to sync wirelessly when the car is on the drive is a bonus as well) but I wanted to see how hard it would be to do a full head unit integration...

Well, SoundGate, the folks who made the original ZuneCORE module I was using have just released their head unit integration for a long list of manufacturers - and my Mustang just happened to be on the list! So I had a small challenge of getting the FDZN4 unit installed in my Pony over the weekend.

Installation was remarkably straight-forward. I'm not the most technical of folks but managed it with no more tools than a cross head screwdriver, one socket and some electrical tape to hold things in place. In less than an hour I was able to use the controls on the factory original stereo to control the Zune as though it was an integral part of the car.

They say a picture tells a thousand words, so here's some pictures of my little installation:

If you're not a Zune user yet you should check it one out. If you have a Zune and wonder how you can integrate it with your car or boat check out SoundGate or the Zune Accessories site for other ways to enhance your listening and viewing experience. I'm wondering if I can feed the video out to a rear seat monitor now for Rhiannon...



MIX09 is Coming - Random Blog Bling time again

clock November 21, 2008 12:01 by author offbeatmammal

MIX09 is the Microsoft event of the year for all things web, so if you don't know what it is you should head over to VisitMIX and find out.

If you do know, you probably want to promote it... and just displaying the same old image for every visitor is so old fashioned, so I turned to my handy 4 lines of javascript to spice things up a little...

   1:  <script type="text/javascript"> 
   2:  var v1= Math.round(Math.random() * 6) + 1;
   3:  document.write('<br><a href="http://2009.VisitMix.com"><img src="http://blog.offbeatmammal.com/samples/MIX09/MIX09_BlogBling_' +v1 + '.jpg" border="0" alt="Visit MIX09"></a>');
   4:  </script>

or... even easier is to just insert this one line of Javascript into your page and as I find new bling I can update it automatically

<script type="text/javascript" src="http://blog.offbeatmammal.com/samples/mix09/mix09bling.js"></script>

if you define two variables in your javascript before you call the random blog bing script then you can over-ride the width and height - just like this

<script type="text/javascript">
var bling_width=120;
var bling_height=160;
</script>
<script type="text/javascript" src="http://blog.offbeatmammal.com/samples/mix09/mix09bling.js"></script>

and you can see the results here (just refresh the page to see it change)



Small Basic

clock November 11, 2008 21:05 by author offbeatmammal

SmallBasic Although I started my adventures in programming in Assembler (65c02, 68000) it was probably the discover of BASIC (I still remember it stands for "Beginners All-purpose Symbolic Instruction Code"!) that showed my that computers could be fun (nerd alert!)

I used various forms of BASIC on a wide range of machines - Atom, BBC B, MSX, Oric, RML, ZX81 etc - before PCs became a more regular feature in my life and QuickBASIC was often a quick and easy way to get things done in the days of DOS. With the rise of Windows Visual Basic became the de facto way that many developers were first introduced to programming.

Time passed and the development environment got more complex and VB "grew up", gained some object oriented type features and became a member of the .Net family of languages. It was no longer an easy starting point for new developers - and languages like C# and Java became more prominent.

Well, that simple, easy to get started concept is back. And in keeping with the aim the name says it all - Small Basic. It's not trying to be big and clever, but as a good way for kids to get started and see results quickly.

In it's default form there are only 15 keywords - but even so it's petty capable. The development environment features all the things you'd expect from a modern platform such as Intellisense and context sensitive help. The neat this though is that it's an extensible environment so other developers can add features and capabilities to the base product to help it grow.

Check it out at the MSDN DevLabs (the same folks who bring you PopFly), read more at their blog and don't forget to check out their "Hello World"!

I wonder how long it'll take me to re-write "snake" ;)



Search

Calendar

<<  January 2009  >>
SuMoTuWeThFrSa
28293031123
45678910
11121314151617
18192021222324
25262728293031
1234567

Sign in

Twitter


    follow OffBeatMammal at http://twitter.com


    Donate unused CPU cycles with BOINC Stats and Account Management from BOINCStats.com
     

    Blogroll

    Archive

    Tags

    Categories


    Disclaimer

    The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

    © Copyright 2009