Video Peggy in action

VideoPeggy - 09


For a while we've been meaning to try out Jay Clegg's TWI-video hack for the Peggy 2, and we must say, it's pretty nifty. Using this routine, we can take webcam video (e.g., from our MacBook Pro's built-in camera), sample it in a Processing routine, and send it to be displayed on the 625 LEDs of the Peggy 2.


Some months ago we wrote about Jay's previous project: sending video to a Peggy 2 with a hardware serial port added.

While that's pretty impressive, it's also a bit invasive, since it requires rewiring the Peggy board. The new version of the project streams data to the Peggy 2 microcontroller over its TWI (also known as I2C) interface-- a separate serial interface that's available. An external Arduino board (or equivalent) sits between the host computer and the Peggy as a serial-to-TWI (I2C) converter.


VideoPeggy - 03 VideoPeggy - 05

VideoPeggy - 06

While Jay used a stock Arduino board in his demo, we just used a hacked "business card" breakout board, wired up where the battery box normally goes. The important part-- no matter which version you are using is that the two TWI interface pins SDA (aka "Analog 4") and SCL (aka "Analog 5") are wired together between the Peggy and the Arduino. It's straight-across wiring, so that pins SDA of both chips are wired together, and pins SCL of both chips are wired together. (The boards also have to share a common ground.) For our parasitic version, we also powered the board from the Peggy 2, so that we wouldn't need an additional power supply.

Since there are two microcontrollers, you'll need one program for each. You can download the programs for both at the bottom of this page on Jay's site. One program runs on the Peggy, and just waits for (or displays) incoming video data. The other program, for the intermediary Arduino, acts as a serial-TWI converter.


VideoPeggy - 01

The host computer side software is written in Processing. You can download the Processing sketch here (4 kB .pde file).

When it runs, it takes video input from a connected webcam (subject to the limitations of the Processing video capture library). The data is converted to grayscale, and drawn as a 25x25 grid of round dots, simulating the Peggy display. (This works without a Peggy as well, just in case you want to play with it.)


VideoPeggy - 02

And, when hooked up correctly, the video shows up on the Peggy.


Embedded below is a short video (without narration) showing the VideoPeggy in action. If you can't see it here, click through to flickr for the video. Performance seems to be good at about 15-17 frames per second with 16 levels of grey.


Update: We've uploaded a version of the TWI-receive software for the Peggy 2, formatted as an Arduino sketch and verified to work on both the ATmega168 and ATmega328P. You can download it here.

15 comments

The following comments are owned by whomever posted them. This site is not responsible for what they say.
Authored by: Anonymous on Wednesday, February 18 2009 @ 09:09 AM PST Video Peggy in action
Is the link on this page to the MirrorPeggy.pde correct? It does not create a 25x25 grid for me. It creates a row of 4 small video images with varying amounts of blur.
Authored by: Windell on Thursday, February 19 2009 @ 01:39 AM PST Video Peggy in action
I've just verified that it works okay on another computer-- Anyone else have a report?

---
Windell H. Oskay
drwho(at)evilmadscientist.com
http://www.evilmadscientist.com/
Authored by: Anonymous on Thursday, February 19 2009 @ 05:35 AM PST Video Peggy in action
The code seems to run fine for me, I just don't get a 25x25 display. I get 4 small video windows in a row...each about 1.5 inches square that display the video from my isight camera. The two windows in the center are somewhat blurry. I'm not sure how this could possibly run so much differently using the same code???
Authored by: Anonymous on Thursday, February 19 2009 @ 05:58 AM PST Video Peggy in action
Never mind...of course it was my mistake. Too many Processing windows open.
Authored by: Anonymous on Wednesday, February 18 2009 @ 06:30 PM PST Video Peggy in action
Great project. Just a note on the color reduction to 16 grey levels.

If you add a tiny random element into the color, specifically +/- half a grey level (in your case +/-8 if you're converting from 256 to 16 levels) and then downsampling the color you'll lose the banding effect (called Mach Banding) and get a smoother better result.

You don't have to use random noise, you can also use a regular grid of constant offsets called an "Ordered dithering" mask, but the random idea works best for temporal data (stuff that changes over time) as the human visual system is very forgiving of randomness.
Authored by: Anonymous on Sunday, June 07 2009 @ 11:42 AM PDT Video Peggy in action
I have given up trying to get this to work with windows and my webcam, gonna try and find a macbook on ebay, what spec machine are you using here to get those framerates?

thanks.
Authored by: Windell on Sunday, June 07 2009 @ 11:51 AM PDT Video Peggy in action
If you are having trouble getting this to work "at all," the problem probably isn't one of frame rate-- you may have a bad connection, or perhaps the wrong program installed on one of the chips. You can also try adjusting the frame rate manually. In the processing program, search for "frames per second" -- which is by default set to 15, I think. Try changing that to 1 or 5, and see if that makes any difference.

---
Windell H. Oskay
drwho(at)evilmadscientist.com
http://www.evilmadscientist.com/
Authored by: Anonymous on Sunday, June 07 2009 @ 12:13 PM PDT Video Peggy in action
Im not that far yet, havn't even ordered the peggy. Im just having an intial play with with processing to make sure this is the right solution for my project. It seems that there are far two many problems trying to use it in a windows environment, problems with video capture, quicktime and java... Its about time I got hold of a used mac, so really just wondering what spec is needed to get that kind of frame rate?

thanks
Authored by: Windell on Sunday, June 07 2009 @ 12:22 PM PDT Video Peggy in action
We were able to get decent performance on just about any recent-vintage mac, even a slow-as-a-slug macbook air. Maybe 1.5 GHz Intel Core Duo would be a good spec to aim for.

---
Windell H. Oskay
drwho(at)evilmadscientist.com
http://www.evilmadscientist.com/
Authored by: Anonymous on Saturday, July 11 2009 @ 11:28 AM PDT Video Peggy in action
How would I go about flipping the video horizontally, cant find anything in the settings so think it needs to be done in the code? but have no idea...

Im using a source from a usb capture.

thanks.
Authored by: Windell on Saturday, July 11 2009 @ 11:59 AM PDT Video Peggy in action
You could do this at any stage: on the computer, in the translation to I2C or on the Peggy-- all depends where you're most comfortable programming.

---
Windell H. Oskay
drwho(at)evilmadscientist.com
http://www.evilmadscientist.com/
Authored by: Anonymous on Monday, July 13 2009 @ 12:59 AM PDT Video Peggy in action
...comfortable programming - no where really!

I'm assuming I need to change this in processing:

int loc = (video.width - x) + y*video.width; // Reversing x to mirror the image

however nothing seems to happen when I change it, any advice?

thanks.
Authored by: Windell on Monday, July 13 2009 @ 01:16 AM PDT Video Peggy in action
As I said, you don't *need* to do it in processing-- it can be done at any stage in the pipeline.

But, if you want to do it in processing, replace this line:
loc = (video.width - xs - 1) + ys*video.width;
with this:
loc = xs + ys*video.width;

---
Windell H. Oskay
drwho(at)evilmadscientist.com
http://www.evilmadscientist.com/
Authored by: Anonymous on Wednesday, July 15 2009 @ 04:30 PM PDT Video Peggy in action
Is it possible to get a copy of the peggy firmware as an arduino sketch? as I'm having difficulties porting it using the instructions provided, and only have the usb-ttl ftdi cable.
Authored by: Windell on Wednesday, July 15 2009 @ 11:55 PM PDT Video Peggy in action
Yes, we've just posted a link to it at the bottom of the article.

---
Windell H. Oskay
drwho(at)evilmadscientist.com
http://www.evilmadscientist.com/

Welcome to Evil Mad Scientist Laboratories. New projects are posted every Wednesday.


Bookmark EMSL

EMSL RSS Feed
Twitter: EMSL
del.icio.us
feedburner
Feed on Google Reader
YouTube Channel
Add technorati Fave

technorati search

Subscribe to get new articles by E-mail:

E-mail address:


Preview | Powered by FeedBlitz

My Account





Sign up as a New User
Lost your password?

Who's Online

Guest Users: 2

Forumposts

Order: New Views Posts
Latest 5 Forum Posts
 
Re: Ferritc core sub..
 By:  npkeith
 On:  Friday, November 20 2009 @ 10:34 AM PST
 Views 0 Replies 0
Re: alphanumeric led..
 By:  karlgg
 On:  Thursday, November 19 2009 @ 10:14 PM PST
 Views 0 Replies 0
Re: alphanumeric led..
 By:  Leviathan34
 On:  Thursday, November 19 2009 @ 07:21 PM PST
 Views 0 Replies 0
Re: 0 of 9 LEDs work..
 By:  Windell
 On:  Thursday, November 19 2009 @ 12:52 PM PST
 Views 0 Replies 0
Re: 0 of 9 LEDs work..
 By:  michael pechner
 On:  Thursday, November 19 2009 @ 11:40 AM PST
 Views 0 Replies 0

DIY Hardware for Electronic Art


Interactive LED Panels


Meggy Jr RGB
LED matrix game
development kit.


Business-card sized
AVR target boards


Peggy 2
LED Pegboard kits