Re: RaspiLight (ambient light)


136 posts   Page 2 of 6   1, 2, 3, 4, 5, 6
by dominicclifton » Mon Oct 08, 2012 11:03 pm
Is performing a grab not possible then or is it just too slow? I'm having performance issues with my XBMC modifications at the moment.
Posts: 27
Joined: Thu Aug 23, 2012 10:40 pm
by dominicclifton » Mon Oct 08, 2012 11:04 pm
I did a few commits today that at least makes full 1080p videos like Avatar play back without issue?

Here's a video of my work in action:

http://youtu.be/AP2fJgS-b8g

Installation pictures here:

https://www.facebook.com/media/set/?set ... 828&type=3

Source here:

http://github.com/hydra/xbmc
Posts: 27
Joined: Thu Aug 23, 2012 10:40 pm
by plfort » Tue Oct 09, 2012 9:12 am
I think it is just not possible to grab frame while a video is playing.
I managed to make it works with another PC running XBMC (like you) but not with xbmc and lights on the Rpi.
With raspbmc, when grabbing frames during video playback, it is the frames behind the video (XBMC UI for 1 or 2 frames and the next frames are black)
What I understand is OMXplayer uses overlay to render video, so we don't have access to the framebuffer
Posts: 18
Joined: Tue Jul 03, 2012 11:26 pm
Location: Grenoble
by dominicclifton » Tue Oct 09, 2012 12:32 pm
Well, my approach at first was to access the image data during the rendering process via a callback by using RenderManager to give my code the image. However this was problematic as some videos work but other ones that are encoded differently caused my code to crash because there's no checking going on in the XBMC code and some XBMC data structures are not correctly initialised and the image format is not accessable from the YUV12Image structure (iirc).

My second approach has been to hook into the code that takes screenshots and just continually take screenshots (without saving to disk, obviously) and process them. This uses a bit of CPU time and causes the mouse pointer to be less responsive in the menus so I tweaked it and bit and it's usable and working but by no means optimal yet.

After talking to the guy that wrote boblight on IRC last night in the #xbmc channel on FreeNode it seems XBMC has something called CRenderCapture which might be able to be used by my C++ code. I skipped over that when I encountered it because I thought it was something to do with PVRs. heh!

It might be worth you having a look to see if the boblight xbmc python code can successfully get a screenshot capture. Here's the code you need:

https://github.com/bobo1on1/script.xbmc ... default.py

Specifically take a look at the process_boblight(): and maybe hook a debugger in and dump out RGB values to the console rather than allowing it to send the data over the network to a boblightd process.
Posts: 27
Joined: Thu Aug 23, 2012 10:40 pm
by plfort » Tue Oct 09, 2012 1:56 pm
I use boblight daemon on the raspberry and XBMC boblight plugin on the client (ubuntu) to display lights in my project, so yes, the boblight plugin can make capture and it works great !
But as I told you, when XBMC runs on the rpi (with the boblight plugin and the daemon), it can't make capture of the video, because the video is decoded by the GPU and it uses another memory space (I guess).

I modified the plugin code to write capture on disk, so when I start a video it results to 1 or 2 frames of the XBMC UI (just before the video is displayed) and black frame for the rest (when the video is displayed).
Posts: 18
Joined: Tue Jul 03, 2012 11:26 pm
Location: Grenoble
by Hofie » Fri Oct 12, 2012 9:18 pm
WOW!!!

That is just awsome. Will it work with 2 Raspberrys, on for watching one for ambient light playback?
Posts: 23
Joined: Mon Jun 11, 2012 10:09 pm
by plfort » Sat Oct 13, 2012 3:54 pm
For the moment, no, because you can't take screenshot on the raspberry while playing video.
You need a PC with XBMC and a raspberry for lights
Posts: 18
Joined: Tue Jul 03, 2012 11:26 pm
Location: Grenoble
by ciggybumly » Wed Oct 17, 2012 1:24 pm
Hi

Sorry to ask the question, but im looking at doing a DIY ambilight system, would you say its best to go down the Raspberry Pi route or the Arduino route?

Looking at controlling a 4m strip of LED's that use LPD8806 addressable LED's, the setup would be a HTPC running something like XMBC, and either the Pi or Arduino for the lights.

Cheers

Tim
Posts: 1
Joined: Wed Oct 17, 2012 1:19 pm
by dominicclifton » Thu Oct 18, 2012 12:34 am
The Pi has loads more resources than an ardiuno. If you're making a custom device that just does one thing an arduino might be suitable. But from what I read people driving lots of LEDs found the basic arduino's a bit slow. Have a look at existing projects and code and see what you can find out.
Posts: 27
Joined: Thu Aug 23, 2012 10:40 pm
by VZoltan » Thu Oct 18, 2012 5:11 am
dominicclifton wrote:The Pi has loads more resources than an ardiuno. If you're making a custom device that just does one thing an arduino might be suitable. But from what I read people driving lots of LEDs found the basic arduino's a bit slow. Have a look at existing projects and code and see what you can find out.


Can u give us a "how-to" page with step by step instructions and a picture about leds connecting into the pi, please?
Posts: 179
Joined: Sat Jun 02, 2012 10:00 pm
by dominicclifton » Fri Oct 19, 2012 12:07 am
Sure.

Hook up the raspberry pi as per this diagram:

http://learn.adafruit.com/light-paintin ... i/hardware

Ensure you use a common ground when wiring up. I found the LEDs did not work if i powered the RPI and LEDs seperately. I found an old 5V 2A PSU I had lying around and that is fine for my WS2801 104 LEDs.

LED strip or Pixel chains work fine as long as you have either WS2801 or LPD8806 or LPD6803 IC's in you LEDs. Avoid the LPD6803 if you can as it doesn't support as many colours.

Install Python and Git on your raspberry pi (via apt-get).

These are the python libraries i have installed, some may already be installed on your Pi, can't remember which ones were 100% required. Ask the author of PixelPi if you get stuck with python related stuff.

ii idle-python2.7 2.7.3~rc2-2.1 all IDE for Python (v2.7) using Tkinter
ii idle-python3.2 3.2.3-2 all IDE for Python (v3.2) using Tkinter
ii libpython2.7 2.7.3~rc2-2.1 armhf Shared Python runtime library (version 2.7)
ii python 2.7.3~rc2-1 all interactive high-level object-oriented language (default version)
ii python-cwiid 0.6.00+svn201-3 armhf library to interface with the wiimote
ii python-dbus 1.1.1-1 armhf simple interprocess messaging system (Python interface)
ii python-dbus-dev 1.1.1-1 all main loop integration development files for python-dbus
ii python-gi 3.2.2-1 armhf Python 2.x bindings for gobject-introspection libraries
ii python-gobject-2 2.28.6-10 armhf deprecated static Python bindings for the GObject library
ii python-imaging 1.1.7-4 armhf Python Imaging Library
ii python-imaging-tk 1.1.7-4 armhf Python Imaging Library - ImageTk Module
ii python-minimal 2.7.3~rc2-1 all minimal subset of the Python language (default version)
ii python-numpy 1:1.6.2-1 armhf Numerical Python adds a fast array facility to the Python language
ii python-pygame 1.9.1release+dfsg-6 armhf SDL bindings for games development in Python
ii python-smbus 3.1.0-2 armhf Python bindings for Linux SMBus access through i2c-dev
ii python-support 1.0.15 all automated rebuilding support for Python modules
ii python-tk 2.7.3-1 armhf Tkinter - Writing Tk applications with Python
ii python2.7 2.7.3~rc2-2.1 armhf Interactive high-level object-oriented language (version 2.7)
ii python2.7-dev 2.7.3~rc2-2.1 armhf Header files and a static library for Python (v2.7)
ii python2.7-minimal 2.7.3~rc2-2.1 armhf Minimal subset of the Python language (version 2.7)

I also have RPi.GPIO-0.4.0a installed (I had to download it and build it from source - you may find the raspbian package works but it stopped working for me after I did an apt-get upgrade on my pi, grr.

Download my code from github (or fork it and download your own fork):

git clone git://github.com/hydra/PixelPi.git

cd PixelPi
git checkout ambipi

If you've not used git before then visit gitready.com or other git sites

run PixelPi in my new AmbiPi mode (only available from my fork currently), set your chip, ip/port and leds as appropriate. sudo is required because of the way the python gpio libraries work.

sudo python pixelpi.py ambipi --chip WS2801 --udp-ip 192.168.1.142 --udp-port 20434 --num_leds 104

You can use the fade, chase, all_on and all_off modes to test your LED and wiring first.

If you use the all_on mode of pixel pi to test you can see if you need more power as the lights might not be bright enough or your Pi might suffer from low voltage due to the load. I also applied power at BOTH ENDS of each chain/strip. otherwise the lights at one end are not as bright as the other end.

Then for the XBMC side of things... Ideally you'll want to be able to download and build XBMC yourself but that is the best way. You'll need visual studio (the free one works) and a git client.

Fork my XBMC repository and checkout the appropriate branch and build it.

You'll need to make sure the dependency dll's are copied to the right place in order to run it.

I'll package up my work-in-progress build and attempt to attach it to this thread in a few minutes.

Once you've got XBMC up and running find the AmbiPi options in the menus - System/Input Devices/Peripherals/AmbiPi.

Enable it and set the IP address of the Pi. the default port should be kept at port 20434.

Ensure your Pi and your PC can talk to each other via UDP on that port. i.e. check your firewalls!

Once you've done that the LED's should light up and you're good to go!

After that you may wish to ensure that PixelPi starts automatically on your Pi when it starts up. That I'll leave as an exercise to the reader but if you create any shell scripts or similar please share them with me and I can include them with the project.

OK?
Last edited by dominicclifton on Fri Oct 19, 2012 12:33 am, edited 1 time in total.
Posts: 27
Joined: Thu Aug 23, 2012 10:40 pm
by dominicclifton » Fri Oct 19, 2012 12:30 am
Download an XBMC build from here:

http://hydraservices.com/files/ambipi

Ensure you backup your existing XBMC profile before you use it.
If you encounter problems use a fresh XBMC profile.

profiles (on windows 7) are stored in: C:\Users\<username>\AppData\Roaming\XBMC

Note that this is an unstable build of XBMC (but it has been fine for me since I built it). Post on the XBMC mailing list or #xbmc irc channel on freenode for non-ambipi related issues.

If you want to build it yourself then please consult the xbmc site:

http://wiki.xbmc.org/index.php?title=Ho ... or_Windows

Enjoy!
Posts: 27
Joined: Thu Aug 23, 2012 10:40 pm
by VZoltan » Fri Oct 19, 2012 8:22 am
Thank you so much for this very detailed How-to!

I will give it a try when my led arrives in the middle id the next week, maybe at the weekend.

Ive ordered this:
http://www.ebay.com/itm/150889364507

I believe this is the exact same as yours so it should be working. Right?

Thanks again! Have a nice weekend! (And try to get it work w/o pc on the pie alone itself :) if u have more free time :) )
Posts: 179
Joined: Sat Jun 02, 2012 10:00 pm
by Hofie » Fri Oct 19, 2012 10:20 pm
The Pi has loads more resources than an ardiuno. If you're making a custom device that just does one thing an arduino might be suitable. But from what I read people driving lots of LEDs found the basic arduino's a bit slow. Have a look at existing projects and code and see what you can find out.


I got the 512MB RAM Version, is that enough resource? I guess it is not but I do have a little hope...
Posts: 23
Joined: Mon Jun 11, 2012 10:09 pm
by dominicclifton » Fri Oct 19, 2012 10:43 pm
I got the 512MB RAM Version, is that enough resource?


I was referring to CPU resources.
Posts: 27
Joined: Thu Aug 23, 2012 10:40 pm
by freeweber » Sat Oct 20, 2012 3:35 pm
thanks dominicclifton for the step-by-step guide :-)
Where is PixelPi with udp support?
I tried your steps, and get an error:
pixelpi.py ambipi: error: argument --tcp-ip is required

seems like i have an old version of pixelpi.py? Where can I find a newer one?

Bye
Georg
Posts: 6
Joined: Thu Sep 27, 2012 5:36 pm
by dominicclifton » Sat Oct 20, 2012 4:28 pm
I'll ensure the latest code is in github ASAP. Sorry about that.
Posts: 27
Joined: Thu Aug 23, 2012 10:40 pm
by dominicclifton » Sun Oct 21, 2012 5:14 pm
Latest AmbiPi code for PixelPi is now there:

https://github.com/hydra/PixelPi/commits/ambipi
Posts: 27
Joined: Thu Aug 23, 2012 10:40 pm
by VZoltan » Sun Oct 21, 2012 5:26 pm
dominicclifton wrote:Latest AmbiPi code for PixelPi is now there:

https://github.com/hydra/PixelPi/commits/ambipi


Ive just finished my adjustable frame for my monitor and my tv :)

Next week ambipi time :)
Posts: 179
Joined: Sat Jun 02, 2012 10:00 pm
by dominicclifton » Sun Oct 21, 2012 6:36 pm
Ive just finished my adjustable frame for my monitor and my tv


Awesome, make sure you guys upload photos of your hardware and pop a video on youtube too!
Posts: 27
Joined: Thu Aug 23, 2012 10:40 pm
by Hofie » Tue Oct 23, 2012 7:08 am
Yea, I want do see that too!!!
Nice Project!
Posts: 23
Joined: Mon Jun 11, 2012 10:09 pm
by VZoltan » Tue Oct 23, 2012 7:16 am
We have holidays in hungary yesterday and today, so i should get my new pi tomorrow, and my led arrives to my friend to the usa today and i hope that she will send id to me today or tomorrow and in that case i will get it friday or next monday, it depens on her free time :(

After everything is working i will post pics and vids of my frame and leds :)
Posts: 179
Joined: Sat Jun 02, 2012 10:00 pm
by mapero » Wed Oct 24, 2012 2:08 pm
I dont have many experience in programming. But with the release of gpu source code maybe RPi can process the images now for Boblight???
Posts: 1
Joined: Wed Oct 24, 2012 2:05 pm
by Hofie » Sun Oct 28, 2012 11:32 am
But with the release of gpu source code maybe RPi can process the images now for Boblight???


That would be great. I am planing to build also a ambient light! Searching now for low cost components. Any suggestion's?
Posts: 23
Joined: Mon Jun 11, 2012 10:09 pm
by VZoltan » Sun Oct 28, 2012 11:54 am
Hofie wrote:
But with the release of gpu source code maybe RPi can process the images now for Boblight???


That would be great. I am planing to build also a ambient light! Searching now for low cost components. Any suggestion's?


i have this:
raspberry pi + http://www.ebay.com/itm/50pc-12mm-Diffused-RGB-LED-Pixels-5V-WS2801-Drivers-Waterproof-Addressable-Color-/150889364507?

or you can buy a kit:
https://www.adafruit.com/products/461
Posts: 179
Joined: Sat Jun 02, 2012 10:00 pm