Showing live video on my 64-pixel display

Hi again!

I really can’t believe it myself, but it works just fine ;-)

All of this is coded in Perl and is only tested on linux. The program uses these modules, if you don’t have them install from CPAN as root. You will need a working version of GCC + all the libs installed.

  • Device::SerialPort
  • Time::HiRes
  • Imager
  • Imager::Screenshot

The module Imager::Screenshot is used to capture a screenshot of my current X11 desktop. It supports taking a full screenshot, capturing a specific window giving the window ID, …, or capturing a arbitrary rectangle with the coordinates (top, left, right, bottom) starting with (0,0) in the top left corner of your screen. Running X11 you can get access to cursor coordinates with the xinput tool like this:

This lists all input devices known to your X11 server:

This displays the cursor position of my input device Mouse[1]:

You can use this information to narrow down the active region for capturing the image.

The image is taken

and scaled down to 8×8 pixels.

Then a single line is extracted using

Pixel data is extracted from the @scanline object using

Reading and transmitting the image data is done with 2 for loops for “row” and “led”.

DONE.

Here’s the code: show_ppm_v4.tgz

To display a box of NxM pixels under your mouse cursor just run the script as

Here’s an example video:

This entry was posted in Arduino., Electronics. and tagged , , , , , . Bookmark the permalink.

12 Responses to Showing live video on my 64-pixel display

  1. andy says:

    hi rob,

    the 8x8s just get better, any way of this working on windows?
    if not il partiton my hdd nd chuck linux on it

  2. robert says:

    Well… the Perl modules I used are also available for windows, so maybe yes.

    In the long run I’m planning to get this working with Processing though, which runs on windows as well.

  3. robert says:

    I’d find it even more attractive, if somebody else (hint hint) did the Processing code for me. More time for my Ikea lamp mod ;-)

  4. ISO-B says:

    What I need to install before I can install those modules? Because my cpan can’t make nothing. I installed some gcc things.

  5. robert says:

    Well, you need gcc + libs and make. Some more packages may be pulled in automatically by dependencies. The CPAN installer will also automatically fetch missing dependencies for the perl modules.

    What error messages do you get ?

  6. ISO-B says:

    I think I didn’t have make and X11.
    I managed to install everything expect Imager::Screenshot.
    Error:’/usr/bin/perl Makefile.PL INSTALLDIRS=site’ returned status 512, won’t make

  7. robert says:

    Hmmm. Did you also install the devel packages (libX11-dev and related) ?

  8. ISO-B says:

    Now I managed to install Imager:Screenshot too. It didn’t made Makefile. Wierd.
    How powerfull computer you used to send data to matrix? Because I made c# program that send image from screen to matrix. It does something too slow because I can when it is changing row color.

  9. robert says:

    My machine is an Athlon64 X2 running in powersave mode at 1GHz. CPU load for the perl script is about 8-10%.

  10. ISO-B says:

    Finally I managed to install and use everything. It works better than my c# program. So I am going to convert your code to windows. After that I can test is problem windows or my program.
    I am running AMD Celeron 1GHz with 512 drr memory.

  11. robert says:

    How do you use the X11 stuff on windows? The screenshot code has win32 support as far as I’ve read.

    Anyway, please let me know when it works.

  12. Pingback: Melkein reaaliajassa kuvaa pöydälle. « ISO-Blogi

Comments are closed.