Configuration for the 3EYE

From B-Wiki
Jump to navigation Jump to search

Original post: https://www.raspberrypi.org/forums/viewtopic.php?t=7397

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

  1. Install the ffmpeg package:

Code: Select all

sudo apt-get install ffmpeg

  1. 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

  1. 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

  1. 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

  1. Plug your PS3 Eye camera into a USB port on the Pi.
  1. 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.

  1. 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

  1. 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.
  1. 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!

  1. You can also browse to the feed on the Pi itself, although this will only work in Chrome and not Midori.
  1. 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

  1. 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.

https://motion-project.github.io/motion_config.html

Configure Octolapse

#!/bin/sh
# Put the arguments sent by Octolapse into variables for easy use
SNAPSHOT_NUMBER=$1
DELAY_SECONDS=$2
DATA_DIRECTORY=$3
SNAPSHOT_DIRECTORY=$4
SNAPSHOT_FILENAME=$5
SNAPSHOT_FULL_PATH=$6

# Check to see if the snapshot directory exists
if [ ! -d "${SNAPSHOT_DIRECTORY}" ];
then
  echo "Creating directory: ${SNAPSHOT_DIRECTORY}"
  mkdir -p "${SNAPSHOT_DIRECTORY}"
fi

# IMPORTANT - You must add gphoto2 to your /etc/sudoers file in order to execute gphoto2 without sudo
# otherwise the following line will fail.
# edit the /etc/sudoers file
# add at the end
# pi ALL = (root) NOPASSWD: /usr/bin/motion

sudo gphoto2 --capture-image-and-download --filename "${SNAPSHOT_FULL_PATH}"

if [ ! -f "${SNAPSHOT_FULL_PATH}" ];
then
  echo "The snapshot was not found in the expected directory: '${SNAPSHOT_FULL_PATH}'." >&2
  exit 1
fi

Configure snapshot script

curl -s http://localhost:8082/0/action/snapshot > /dev/null