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.

25 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 @ 06: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 Wednesday, February 18 2009 @ 10:39 PM 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 @ 02: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 @ 02: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 @ 03: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 @ 08: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 @ 08: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 @ 09:13 AM 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 @ 09:22 AM 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 @ 08: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 @ 08: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 Sunday, July 12 2009 @ 09:59 PM 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 Sunday, July 12 2009 @ 10:16 PM 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: Teeps on Saturday, December 05 2009 @ 12:59 PM PST Video Peggy in action
And what would that line be if I need to flip it vertically?

Thanks so much for the help!
Authored by: Teeps on Saturday, December 05 2009 @ 06:43 PM PST Video Peggy in action
Ok, so I happened to realize that I can just flip the camera upside down for this application, so don't worry about that unless you want the challenge.
Authored by: Anonymous on Wednesday, July 15 2009 @ 01: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 @ 08: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/
Authored by: Anonymous on Monday, March 29 2010 @ 04:16 PM PDT Video Peggy in action
Very cool. Could this be used in conjunction with a POV display for more pixels?
That would really up the coolness factor..
Authored by: Anonymous on Wednesday, June 23 2010 @ 09:19 AM PDT Video Peggy in action
how big is it possible to make this, and what is the cost per sq m?
Authored by: ahmattox on Thursday, April 28 2011 @ 10:55 AM PDT Video Peggy in action
Great project. I seem to have it almost working except the connection between processing and the arduino isn't quite right. It's only refreshing every two seconds or so (inconsistently) and the image seems to be offset by a number of pixels.

Running Jay's test pattern script on the arduino works great.

Any suggestions?
Authored by: Windell on Thursday, April 28 2011 @ 12:37 PM PDT Video Peggy in action
I think that someone reported a similar problem in the forums; check there. And if you need more help, ask for it there, not in the blog comments, please. ;)

---
Windell H. Oskay
drwho(at)evilmadscientist.com
http://www.evilmadscientist.com/
Authored by: Anonymous on Sunday, October 09 2011 @ 01:45 PM PDT Video Peggy in action
Could this work with the Video Experimenter shield - so no computer?
Authored by: Windell on Sunday, October 09 2011 @ 01:49 PM PDT Video Peggy in action
So far as I can see, the Video Experimenter shield does require a computer, and I'm not sure how you would interface that to a Peggy in any case.

---
Windell H. Oskay
drwho(at)evilmadscientist.com
http://www.evilmadscientist.com/
Authored by: Anonymous on Saturday, December 10 2011 @ 05:53 PM PST Video Peggy - more cells via processing code ?
great project -
i played with the code in order to change the resolution
-in order to have more than 25 x 25 cells
and probably combine more than just 1 peggy-
... but didn't succeed yet;

may i ask for any advice on how to proceed
to get more than a 25z25 resolution?
Authored by: Windell on Saturday, December 10 2011 @ 06:09 PM PST Video Peggy - more cells via processing code ?
The tricky thing is how to network the Peggy kits. One way is to use I2C, another is to use a multipoint serial like RS485. Here's one working example: http://hackaday.com/2009/12/19/peggy2-x2-with-video/

---
Windell H. Oskay
drwho(at)evilmadscientist.com
http://www.evilmadscientist.com/
Welcome to Evil Mad Scientist Laboratories. New projects are posted on most Wednesdays.


Bookmark EMSL

EMSL RSS

Evil Mad Linkblog

Twitter: @EMSL

Facebook page
del.icio.us
feedburner
Feed on Google Reader
YouTube Channel

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: 21

DIY Hardware for Electronic Art


The Original Egg-Bot Kit


Octolively
Interactive LED kits


Meggy Jr RGB
LED matrix game
development kit.


Business-card sized
AVR target boards


Peggy 2
LED Pegboard kits

Forumposts

Order: New Views Posts
Latest 10 Forum Posts
 
Re: Wire for Remote LEDs and I..
 By:  dayjerd
 Friday, February 03 2012 @ 06:36 PM PST
Re: Wire for Remote LEDs and I..
 By:  Windell
 Friday, February 03 2012 @ 02:36 PM PST
Re: Wire for Remote LEDs and I..
 By:  dayjerd
 Thursday, February 02 2012 @ 12:47 PM PST
Re: Wire for Remote LEDs and I..
 By:  Windell
 Thursday, February 02 2012 @ 10:55 AM PST
Re: Wire for Remote LEDs and I..
 By:  dayjerd
 Thursday, February 02 2012 @ 05:30 AM PST
Re: Wire for Remote LEDs and I..
 By:  Windell
 Wednesday, February 01 2012 @ 10:21 PM PST
Wire for Remote LEDs and IR LE..
 By:  dayjerd
 Wednesday, February 01 2012 @ 09:07 PM PST
Re: Newbie: adding switches to..
 By:  Windell
 Monday, January 30 2012 @ 10:32 AM PST
Re: Newbie: adding switches to..
 By:  John Fongheiser
 Monday, January 30 2012 @ 10:20 AM PST
Re: Newbie: adding switches to..
 By:  Ugi
 Monday, January 30 2012 @ 08:43 AM PST