LoginSignup
5
5

More than 5 years have passed since last update.

raspberry pi で USBカメラ(c270)から画像/音声入力/出力

Last updated at Posted at 2016-11-19

USBカメラ画像入力

  • fswebcam をインストール
$ apt-get install fswebcam
  • 外から確認するため, sambaをmount (参考)
$ apt-get install cifs-util
$ sudo mount -t cifs //192.168.1.XX/share /mnt -o iocharset=utf8
  • jpeg取得
$ fswebcam /mnt/foo.jpg

USBカメラのマイクから音を入力

カードとデバイス番号を確認する

$ arecord -l
**** ハードウェアデバイス CAPTURE のリスト ****
カード 1: U0x46d0x825 [USB Device 0x46d:0x825], デバイス 0: USB Audio [USB Audio]
  サブデバイス: 1/1
  サブデバイス #0: subdevice #0

録音する (-D plughw:(カード番号),(デバイス番号), -d dulation秒数)

$ arecord -D plughw:1,0 -d 1 -f cd test.wav

マイクボリューム確認 (-c でカード番号を指定), 必要に応じて ssetで調整

$ amixer sget Mic -c 1
Simple mixer control 'Mic',0
  Capabilities: cvolume cvolume-joined cswitch cswitch-joined
  Capture channels: Mono
  Limits: Capture 0 - 16
  Mono: Capture 12 [75%] [24.00dB] [on]

raspberrypi から音を出す (ヘッドフォン端子)

mixierを1に設定する(2=HDMI) (参考)
スピーカだと音が小さくて気が付きにくいので注意

$ sudo amixer cset numid=3 1
$ aplay /usr/share/sounds/alsa/Front_Center.wav

mixerの状態などの確認方法は下記
```shell-session
$ aimixer controls
numid=3,iface=MIXER,name='PCM Playback Route'
numid=2,iface=MIXER,name='PCM Playback Switch'
numid=1,iface=MIXER,name='PCM Playback Volume'
numid=5,iface=PCM,name='IEC958 Playback Con Mask'
numid=4,iface=PCM,name='IEC958 Playback Default'

$ aimixer cget numid=3
numid=3,iface=MIXER,name='PCM Playback Route'
; type=INTEGER,access=rw------,values=1,min=0,max=2,step=0
: values=1

$ aplay -l
**** ハードウェアデバイス PLAYBACK のリスト ****
カード 0: ALSA [bcm2835 ALSA], デバイス 0: bcm2835 ALSA [bcm2835 ALSA]
サブデバイス: 8/8
サブデバイス #0: subdevice #0
サブデバイス #1: subdevice #1
サブデバイス #2: subdevice #2
サブデバイス #3: subdevice #3
サブデバイス #4: subdevice #4
サブデバイス #5: subdevice #5
サブデバイス #6: subdevice #6
サブデバイス #7: subdevice #7
カード 0: ALSA [bcm2835 ALSA], デバイス 1: bcm2835 ALSA [bcm2835 IEC958/HDMI]
サブデバイス: 1/1
サブデバイス #0: subdevice #0
```

5
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
5