Elegor
Posts: 21
Joined: Sun Aug 28, 2011 10:41 pm
Location: UK

Playstation PS3 Eye Streaming

Sun Jun 03, 2012 5:31 pm

Just managed to get my PS3 Eye camera working with the Pi, so thought I'd share how it's done in Debian. The following steps will get the camera and Pi working together as a simple motion detection device with a web stream that you can view on your local network:

1. Install the 'motion' package (http://www.lavrsen.dk/foswiki/bin/view/Motion/WebHome):

Code: Select all

sudo apt-get install motion
2. Install the ffmpeg package:

Code: Select all

sudo apt-get install ffmpeg
3. Edit the /etc/motion/motion.conf file and change the following setting from 'on' to 'off'. This is optional, but will allow the camera to be viewed using another PC on your local network:

Code: Select all

webcam_localhost off
4. If you wish to have basic control over the camera from a web browser (see step 11) then you can change the following setting in the same file to 'off':

Code: Select all

control_localhost off
5. Since the PS3 Eye camera is capable of capturing at a resolution of 640x480, we can make the following further changes to the /etc/motion.conf file:

Code: Select all

width 640
height 640
6. Plug your PS3 Eye camera into a USB port on the Pi.

7. Find out the IP Address of your Pi and make a note of it for step 10:

Code: Select all

ifconfig
This will give the following output:

Code: Select all

eth0      Link encap:Ethernet  HWaddr xx:xx:xx:xx:xx:xx
          inet addr:192.168.32.47  Bcast:192.168.32.255  Mask:255.255.255.0
          inet6 addr: fe80::ba27:ebff:fe40:357a/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:31800 errors:0 dropped:0 overruns:0 frame:0
          TX packets:27108 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:20174919 (19.2 MiB)  TX bytes:29838750 (28.4 MiB)
The address in the above example is 192.168.32.47.

8. Start up the motion application. Note that it has no GUI and can be run from the command line when you first start up the Pi. It doesn't need to run within startx:

Code: Select all

motion -n
9. This will run the software in command-line mode, displaying startup information and errors directly to the console. It also allows it to be stopped using Ctrl-C. If you want to run the software in the background as a 'daemon', simply type 'motion' without the -n switch.

10. If everything has worked okay, you should be able to go to another computer on your network and browse to your Pi's address to see the camera output:

Code: Select all

http://192.168.32.47:8081
Using your Pi's address of course!
11. You can also browse to the feed on the Pi itself, although this will only work in Chrome and not Midori.

12. If you browse to the 'control port' address below, you also get rudimentary control over the motion software:

Code: Select all

http://192.168.32.47:8080
13. Since this is a motion detection package, it automatically detects movement on the camera and creates '.jpg' image and '.swf' video snapshots each time it sees movement on the camera. These are stored in the following directory:

Code: Select all

/tmp/motion
14. Note that these files will build up quite quickly if the camera is pointed at something that moves a lot, so make sure you have plenty of space on your sd card. Also, since the files are stored in /tmp, they will be deleted each time you reboot your Pi.

Scratching the Surface...
The above instructions should be enough to get you going, but the Motion package seems to be capable of a great deal more, so it's worth having a good read of the Motion website (http://www.lavrsen.dk/foswiki/bin/view/Motion/WebHome) to see what else it can do.

Some things you could have a play with:
* Baby/Pet monitor
* Security camera
* Automatically email pictures of movement to you (catch the thief who is stealing from your chocolate stash!)
* Time lapse camera (plants growing, weather, sunrise, etc)

Please post any interesting configurations/uses here!

Edit 1:
I should have pointed out that Motion will work with other USB cameras not just the PS Eye. I couldn't say which ones, but if anyone gets others working then again post the results here.

J_R
Posts: 1
Joined: Mon Jun 04, 2012 12:50 pm

Re: Playstation PS3 Eye Streaming

Mon Jun 04, 2012 12:54 pm

Is that the correct address to get the 'Motion' package? My browser cannot reach it.

(Maybe he's off-line. I'll try again later.)

Elegor
Posts: 21
Joined: Sun Aug 28, 2011 10:41 pm
Location: UK

Re: Playstation PS3 Eye Streaming

Mon Jun 04, 2012 5:03 pm

J_R wrote:Is that the correct address to get the 'Motion' package? My browser cannot reach it.
I just tried it and it works okay for me so give it another go.

User avatar
SN
Posts: 1014
Joined: Mon Feb 13, 2012 8:06 pm
Location: Romiley, UK

Re: Playstation PS3 Eye Streaming

Mon Jun 04, 2012 8:38 pm

Nice...
Steve N – binatone mk4->intellivision->zx81->spectrum->cbm64->cpc6128->520stfm->pc->raspi ?

tokyostormdrain
Posts: 16
Joined: Wed May 30, 2012 6:11 pm

Re: Playstation PS3 Eye Streaming

Mon Jun 04, 2012 9:27 pm

Thanks for the instruction on how to get this up and running.
I'm a n00b at linux so please bare with me.
I edited the motion.conf file based on your instructions after installing motion and ffmpeg.

When I try to run motion, it says it cant find video on /dev/video0, I do have the eyetoy plugged in btw and the light is on.

I tried running dmesg to see that the camera is found which it seems to be. I've had a browse to /dev to see if there were any other video like device names there but cant see any.

Can you suggest what might be going wrong?

Thanks for any help

Elegor
Posts: 21
Joined: Sun Aug 28, 2011 10:41 pm
Location: UK

Re: Playstation PS3 Eye Streaming

Tue Jun 05, 2012 10:48 am

tokyostormdrain wrote:Can you suggest what might be going wrong?
Thanks for any help
You don't mention which distribution you're using, so that might be the problem. I'm using Debian Squeeze (debian6-19-04-2012.zip at http://www.raspberrypi.org/downloads) which has the camera driver module built into the kernel (as I just learned from someone on another thread).

tokyostormdrain
Posts: 16
Joined: Wed May 30, 2012 6:11 pm

Re: Playstation PS3 Eye Streaming

Tue Jun 05, 2012 7:59 pm

Yeah, same debian version for me too

Elegor
Posts: 21
Joined: Sun Aug 28, 2011 10:41 pm
Location: UK

Re: Playstation PS3 Eye Streaming

Tue Jun 05, 2012 8:47 pm

tokyostormdrain wrote:Yeah, same debian version for me too
The other thing to try is running an update in Debian. They may have updated the kernel drivers in a recent update I guess:

Code: Select all

sudo apt-get update
sudo apt-get upgrade
You'll probably need to reboot too.

pi-man-uk
Posts: 62
Joined: Tue May 08, 2012 1:41 pm

Re: Playstation PS3 Eye Streaming

Wed Jun 06, 2012 10:18 am

Really interesting post. I have exactly this setup (same camera, using motion).
I am on arch though.

Elegor - can you help me please - I have a specfic question.

Streaming is working fine for me - but when motion is detected the JPEGs that are saved are viewable but slightly corrupt - example attached.

Interestingly I don't get the problem with another webcam.

Two questions..

1) do you get the same problem
2) if you do - have you a fix/ideas?

Really grateful for any insight as it's working so smashingly well for me at the moment bar this glitch.

I'd love to use a 720p camera - anyone know if possible ?
Attachments
example-snapshot.jpg
example-snapshot.jpg (22.14 KiB) Viewed 130559 times

pi-man-uk
Posts: 62
Joined: Tue May 08, 2012 1:41 pm

Re: Playstation PS3 Eye Streaming

Wed Jun 06, 2012 11:07 am

if it makes a difference I've just noticed that the first image captured is fine, everything after that though suffers from the problem.

Elegor
Posts: 21
Joined: Sun Aug 28, 2011 10:41 pm
Location: UK

Re: Playstation PS3 Eye Streaming

Wed Jun 06, 2012 12:53 pm

I've just run it again and I do get some corruptions similar to the one you posted, but only in 3 of the 58 images that it captured. There could be any one of a number of causes, from bugs in the Motion software through bugs in the camera drivers to lack of horsepower in the Pi itself.

If it happens on all but one of your images, then maybe the fact that you're running Arch Linux, has something to do with it? If you have a spare SD Card, then you could try Debian instead.

Also, did you change the Jpeg compression quality setting? It's set to 75 by default, so maybe raising or lowering this will have an impact?

pi-man-uk
Posts: 62
Joined: Tue May 08, 2012 1:41 pm

Re: Playstation PS3 Eye Streaming

Wed Jun 06, 2012 4:31 pm

Very interesting and helpful.
I was thinking on the same lines as you.
tried the jpeg quality at 10 and 100, no difference.
Then I realised - I'd upped the rez to 640x480, the webcam supports it.
Figured I'd try it at the defaults 352 and 288 apparently.
boom - problem seems to have gone.
Shame as this rez is pretty low - any guesses as to what's happening here? Pi can't handle it ?
Maybe I should try an overclock...

thanks.

User avatar
jbeale
Posts: 4003
Joined: Tue Nov 22, 2011 11:51 pm

Re: Playstation PS3 Eye Streaming

Wed Jun 06, 2012 4:38 pm

If you are automatically saving stills from a video stream to SD card, I wonder if there is a buffering problem when you are busy saving an image and then another one comes in before you are done saving the first one. SD cards (as implemented on the Pi) can be slow. Might make a difference if you save to USB stick or other storage.

pi-man-uk
Posts: 62
Joined: Tue May 08, 2012 1:41 pm

Re: Playstation PS3 Eye Streaming

Wed Jun 06, 2012 4:45 pm

that's interesting and sounds v plausible - thanks. i could try saving to a USB stick.

Would a swap file help - haven't got one configured - I can try that also.

Elegor
Posts: 21
Joined: Sun Aug 28, 2011 10:41 pm
Location: UK

Re: Playstation PS3 Eye Streaming

Wed Jun 06, 2012 5:07 pm

I have my camera resolution set to 640x480, and I'm using a Sandisk Class 4, 4gb SD card. As I mentioned earlier, I get about 5% of the frames with corruptions.

Saving to a USB stick is definitely worth a try, although some of them can be even slower than SD cards! :)

I don't think a swap partition will make a difference as the program doesn't seem to be memory constrained. Even if it was, sending more data to be written to the SD card is likely to make the problem worse not better. Still, there's no harm in trying it out (with the caveat that long-term use of a swap partition is said to reduce the life of the SD Card).

pi-man-uk
Posts: 62
Joined: Tue May 08, 2012 1:41 pm

Re: Playstation PS3 Eye Streaming

Wed Jun 06, 2012 5:35 pm

Tried the swap. Didn't help unfortunately.

Pi is remote so I don't physically have access.

Maybe I've just got a slow SD card in it. Can't quite remember it's type, any tricks to ascertain it's speed.

Will try some tricks "noatime"? in fstab to attempt better performance.

tokyostormdrain
Posts: 16
Joined: Wed May 30, 2012 6:11 pm

Re: Playstation PS3 Eye Streaming

Wed Jun 06, 2012 9:19 pm

Just an update on my progress with this.
I now have my ps3 eyetoy streaming video locally. What I hadn't done was update my firmware.
Thanks for the explanation and help, I've gained a little knowledge, which of course can be a dangerous thing :)

pi-man-uk
Posts: 62
Joined: Tue May 08, 2012 1:41 pm

Re: Playstation PS3 Eye Streaming

Thu Jun 07, 2012 1:40 pm

I tried this - created a small ramdrive and saved the snapshots to it (surely the fastest available storage)..Didn't work though unfortunately - same corruption at 640x480... grrr.

What else ?

User avatar
larrie
Posts: 5
Joined: Tue Jun 12, 2012 3:54 pm

Re: Playstation PS3 Eye Streaming

Tue Jun 12, 2012 4:19 pm

Hi, Thanks for this great tutorial, I hope you maybe able to help with a problem I too am getting the error message when I run motion -n

Cant find video on /dev/video0, I do have the ps3 eye plugged in btw and the light is on.

I tried your suggestion of doing:

Code: Select all

sudo apt-get update
sudo apt-get upgrade
And did a reboot but I still get the Cant find video on /dev/video0 message.

In motion.conf there is the videodevice setting which is set to /dev/video0

I am using the Debian “squeeze” distro, do you know what directory I need to put in the videodevice setting to get it to work?

Many thanks

User avatar
jbeale
Posts: 4003
Joined: Tue Nov 22, 2011 11:51 pm

Re: Playstation PS3 Eye Streaming

Tue Jun 12, 2012 4:43 pm

pi-man-uk wrote:I tried this - created a small ramdrive and saved the snapshots to it (surely the fastest available storage)..Didn't work though unfortunately - same corruption at 640x480... grrr.
It may be that the R-Pi USB drivers simply don't work all the time, causing a number of different problems. See for example
"USB Packet Loss" http://www.raspberrypi.org/phpBB3/viewt ... =28&t=5249
"Running X/LXDE causes packet loss/dmesg errors on networking" https://github.com/raspberrypi/linux/issues/29
"Interrupt collision between smsc95xx and USB storage drivers under heavy load" https://github.com/raspberrypi/firmware/issues/9

Elegor
Posts: 21
Joined: Sun Aug 28, 2011 10:41 pm
Location: UK

Re: Playstation PS3 Eye Streaming

Tue Jun 12, 2012 8:55 pm

larrie wrote:Hi, Thanks for this great tutorial, I hope you maybe able to help with a problem I too am getting the error message when I run motion -n
A couple of things I've realised since making the original post:

1. Before I started, I'd updated the firmware on my SD card to the latest version. Recent versions of the firmware have USB camera drivers built in, whereas the ones on the standard Debian download don't. You'll definitely need to update the firmware before it will work, therefore.

2. I only get problems with frames being corrupted about 5% of the time, whereas others get corruptions on most of the frames. This may be down to the fact that I've overclocked my Pi in /boot/config.txt as follows:
arm_freq=900
gpu_freq=250
sdram_freq=450

See http://elinux.org/RPi_config.txt for config.txt details.

richardtheboffin
Posts: 33
Joined: Thu Apr 19, 2012 12:04 pm

Re: Playstation PS3 Eye Streaming

Fri Jul 13, 2012 11:14 pm

I'm running Denbian squeeze, I've done an update and upgrade but still not seeing the camera (ps3 eyetoy) in /dev.

It's there on lsusb.

Any ideas how to get the camera driver going?

Blaster391
Posts: 16
Joined: Fri Jun 01, 2012 9:45 pm

Re: Playstation PS3 Eye Streaming

Sat Jul 14, 2012 7:30 am

I was going to try something like this, you just saved me a lot of work, thanks!

richardtheboffin
Posts: 33
Joined: Thu Apr 19, 2012 12:04 pm

Re: Playstation PS3 Eye Streaming

Sat Jul 14, 2012 3:01 pm

Any clues on getting the PS3 camera to show up in /dev ?????

richardtheboffin
Posts: 33
Joined: Thu Apr 19, 2012 12:04 pm

Re: Playstation PS3 Eye Streaming

Sat Jul 14, 2012 4:28 pm

OK, did a firmware update using rpi-update and video0 is now present and motion is working!

Return to “Beginners”