さっそくWebカメラをくっつけてみようと
Webカメラを買ってきました。
少し奮発していいのを買いました。


このページを参考にさっそく接続。
http://linux.yebisu.jp/memo/800

root@raspberrypi ~ # lsusb
Bus 001 Device 002: ID 0424:9512 Standard Microsystems Corp.
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp.
Bus 001 Device 005: ID 0411:01a2 BUFFALO INC. (formerly MelCo., Inc.) WLI-UC-GNM Wireless LAN Adapter [Ralink RT8070]

接続前のUSBの状態。ふむふむ。
接続するときに /var/log/messages も見ておこう

root@raspberrypi ~ #
root@raspberrypi ~ # tail  -f /var/log/messages

Mar 13 21:19:36 raspberrypi kernel: [ 1635.527222] usb 1-1.2: new high-speed USB device number 7 using dwc_otg Mar 13 21:19:36 raspberrypi kernel: [ 1635.813889] usb 1-1.2: New USB device found, idVendor=2084, idProduct=0d03 Mar 13 21:19:36 raspberrypi kernel: [ 1635.813924] usb 1-1.2: New USB device strings: Mfr=1, Product=2, SerialNumber=0 Mar 13 21:19:36 raspberrypi kernel: [ 1635.813943] usb 1-1.2: Product: BUFFALO BSW32KM03 USB PC Camera Mar 13 21:19:36 raspberrypi kernel: [ 1635.813960] usb 1-1.2: Manufacturer: Etron Technology, Inc. Mar 13 21:19:36 raspberrypi kernel: [ 1635.831764] uvcvideo: Found UVC 1.00 device BUFFALO BSW32KM03 USB PC Camera (2084:0d03) Mar 13 21:19:36 raspberrypi kernel: [ 1635.839558] uvcvideo: UVC non compliance - GET_DEF(PROBE) not supported. Enabling workaround. Mar 13 21:19:36 raspberrypi kernel: [ 1635.844608] input: BUFFALO BSW32KM03 USB PC Camera as /devices/platform/bcm2708_usb/usb1/1-11-1.21-1.2:1.0/input/input2 Mar 13 21:19:36 raspberrypi kernel: [ 1635.961702] usb_audio: Warning! Unlikely big volume range (=4096), cval->res is probably wrong. ^C root@raspberrypi ~ # ^C root@raspberrypi ~ # root@raspberrypi ~ # lsusb Bus 001 Device 002: ID 0424:9512 Standard Microsystems Corp. Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp. Bus 001 Device 007: ID 2084:0d03 Bus 001 Device 005: ID 0411:01a2 BUFFALO INC. (formerly MelCo., Inc.) WLI-UC-GNM Wireless LAN Adapter [Ralink RT8070]

認識はされたみたい。
でも型番とか出てこないので不安だなぁ。
ちぇく。

root@raspberrypi ~ # lsusb -v -d 2084:0d03

Bus 001 Device 007: ID 2084:0d03 Device Descriptor: bLength 18 bDescriptorType 1 bcdUSB 2.00 bDeviceClass 239 Miscellaneous Device bDeviceSubClass 2 ? bDeviceProtocol 1 Interface Association bMaxPacketSize0 64 idVendor 0x2084 idProduct 0x0d03 bcdDevice 0.02 iManufacturer 1 Etron Technology, Inc. iProduct 2 BUFFALO BSW32KM03 USB PC Camera iSerial 0 bNumConfigurations 1 Configuration Descriptor: bLength 9

うまく認識されているようです。
さっそくライブカメラアプリを入れてみることに。
使うのは motion。

root@raspberrypi ~ # apt-get -y install motion
Reading package lists… Done
Building dependency tree
Reading state information… Done
The following extra packages will be installed:
  ffmpeg libav-tools libavcodec53 libavdevice53 libavfilter2 libavformat53
  libavutil51 libdc1394-22 libdirac-encoder0 libgsm1 libjack-jackd2-0
  libmp3lame0 libmysqlclient18 libopencv-core2.3 libopencv-imgproc2.3

いっぱいメッセージが出てきて無事終了。
設定ファイルを編集します。
先ほどのURLを参考に一部を書き換えます。

root@raspberrypi ~ # vi /etc/motion/motion.conf
# Start in daemon (background) mode and release terminal (default: off)
###daemon off
daemon on

File to store the process ID, also called pid file. (default: not defined)

###process_id_file /var/run/motion/motion.pid process_id_file /var/run/motion.pid

V4L2_PIX_FMT_SN9C10X : 0 ‘S910′

V4L2_PIX_FMT_SBGGR8 : 1 ‘BA81′

V4L2_PIX_FMT_MJPEG : 2 ‘MJPEG’

V4L2_PIX_FMT_JPEG : 3 ‘JPEG’

V4L2_PIX_FMT_RGB24 : 4 ‘RGB3′

V4L2_PIX_FMT_UYVY : 5 ‘UYVY’

V4L2_PIX_FMT_YUYV : 6 ‘YUYV’

V4L2_PIX_FMT_YUV422P : 7 ’422P’

V4L2_PIX_FMT_YUV420 : 8 ‘YU12′

###v4l2_palette 8 v4l2_palette 6

Image width (pixels). Valid range: Camera dependent, default: 352

###width 320 width 640

Image height (pixels). Valid range: Camera dependent, default: 288

###height 240 height 480

Maximum number of frames to be captured per second.

Valid range: 2-100. Default: 100 (almost no limit).

###framerate 2 framerate 5

Output ‘normal’ pictures when motion is detected (default: on)

Valid values: on, off, first, best, center

When set to ‘first’, only the first picture of an event is saved.

Picture with most motion of an event is saved when set to ‘best’.

Picture with motion nearest center of picture is saved when set to ‘center’.

Can be used as preview shot for the corresponding movie.

###output_normal on output_normal off

Use ffmpeg to encode mpeg movies in realtime (default: off)

###ffmpeg_cap_new on ffmpeg_cap_new off

Locate and draw a box around the moving object.

Valid values: on, off and preview (default: off)

Set to ‘preview’ will only draw a box in preview_shot pictures.

###locate off locate on

Target base directory for pictures and films

Recommended to use absolute path. (Default: current working directory)

###target_dir /tmp/motion target_dir /var/tmp/motion

The mini-http server listens to this port for requests (default: 0 = disabled)

###webcam_port 8081 webcam_port 8088

Restrict webcam connections to localhost only (default: on)

###webcam_localhost on webcam_localhost off

TCP/IP port for the http server to listen on (default: 0 = disabled)

###control_port 8080 control_port 8089

Restrict control connections to localhost only (default: on)

###control_localhost on control_localhost off


よーし!起動!!

root@raspberrypi ~ # motion
[0] Processing thread 0 - config file /etc/motion/motion.conf
[0] Motion 3.2.12 Started
[0] Motion going to daemon mode


やったー!!!


ちなみに停止するときはこうです。