PCA-DAV2

0pt

Linuxと暗視カメラで監視システムを構築しようと思い、市販の赤外線カメラとキャプチャユニットを買ってきました。

暗視カメラ(赤外線カメラ)


http://www.ykmusen.co.jp/cctv/okugaicamera/mtc-840cm.html
↑ここに書かれているカメラを購入しました。

暗視カメラ動作中はたくさんのLEDが(弱く)赤く点灯し、王蟲みたいな感じに地味にひかります。

秋葉原の電気屋のおじちゃんにいろいろ試してもらい、結局これに落ち着きました。
屋内で使ってみましたが、4-5mであれば結構余裕で状態が確認できます。

ちなみに、アナログカメラなので解像度がさほど高くないと感じる人もいるかもしれないです。

キャプチャユニット(USB)

Princeton USBビデオキャプチャーユニット デジ造 Vista対応版

これです。このサイトを見て製品を決めました。

が、上記サイトの設定では動きませんでした。なんでだろう?チップセットが違うのかな…

上記サイトに、/etc/modprobe.d/em28xx.confを作成して編集する行がありますが、自分の環境(Ubuntu 11.x)では次のようになりました。

options em28xx card=68


めちゃくちゃ面倒くさかったのですが、1番から順番に試していきました。正常に動作すると、/var/log/messagesにこんな感じの出力が出てきます。

em28xx: New device USB 2861 Device @ 480 Mbps (eb1a:2861, interface 0, class 0)
em28xx #0: chip ID is em2860
em28xx #0: i2c eeprom 00: 1a eb 67 95 1a eb 61 28 50 00 11 03 6a 22 00 00
em28xx #0: i2c eeprom 10: 00 00 04 57 06 02 00 00 00 00 00 00 00 00 00 00
em28xx #0: i2c eeprom 20: 02 00 01 00 f0 10 01 00 00 00 00 00 5b 00 00 00
em28xx #0: i2c eeprom 30: 00 00 20 40 20 80 02 20 01 01 00 00 00 00 00 00
em28xx #0: i2c eeprom 40: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
em28xx #0: i2c eeprom 50: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
em28xx #0: i2c eeprom 60: 00 00 00 00 00 00 00 00 00 00 22 03 55 00 53 00
em28xx #0: i2c eeprom 70: 42 00 20 00 32 00 38 00 36 00 31 00 20 00 44 00
em28xx #0: i2c eeprom 80: 65 00 76 00 69 00 63 00 65 00 00 00 00 00 00 00
em28xx #0: i2c eeprom 90: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
em28xx #0: i2c eeprom a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
em28xx #0: i2c eeprom b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
em28xx #0: i2c eeprom c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
em28xx #0: i2c eeprom d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
em28xx #0: i2c eeprom e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
em28xx #0: i2c eeprom f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
em28xx #0: EEPROM ID= 0x9567eb1a, EEPROM hash = 0x1369388a
em28xx #0: EEPROM info:
em28xx #0: AC97 audio (5 sample rates)
em28xx #0: 500mA max power
em28xx #0: Table at 0x04, strings=0x226a, 0x0000, 0x0000
em28xx #0: Identified as Terratec AV350 (card=68)
VIA 82xx Audio 0000:00:11.5: PCI INT C -> Link[LNKC] -> GSI 10 (level, low) -> IRQ 10
tvp5150 1-005c: chip found @ 0xb8 (em28xx #0)
em28xx #0: Config register raw data: 0x50
em28xx #0: AC97 vendor ID = 0x83847650
em28xx #0: AC97 features = 0x6a90
em28xx #0: Sigmatel audio processor detected(stac 9750)
tvp5150 1-005c: tvp5150am1 detected.
type=1505 audit(1305472679.126:7): operation="profile_replace" pid=635 name=/sbin/dhclient3
type=1505 audit(1305472679.134:8): operation="profile_replace" pid=635 name=/usr/lib/NetworkManager/nm-dhcp-client.action
type=1505 audit(1305472679.134:9): operation="profile_replace" pid=635 name=/usr/lib/connman/scripts/dhclient-script
type=1505 audit(1305472679.142:10): operation="profile_replace" pid=636 name=/usr/sbin/mysqld
type=1505 audit(1305472679.150:11): operation="profile_replace" pid=637 name=/usr/sbin/tcpdump
type=1503 audit(1305472681.334:12): operation="open" pid=808 parent=807 profile="/usr/sbin/mysqld" requested_mask="r::" denied_mask="r::" fsuid=0 ouid=0 name="/sys/devices/system/cpu/"
type=1503 audit(1305472681.470:13): operation="open" pid=828 parent=827 profile="/usr/sbin/mysqld" requested_mask="r::" denied_mask="r::" fsuid=0 ouid=0 name="/sys/devices/system/cpu/"
em28xx #0: v4l2 driver version 0.1.2
type=1503 audit(1305472681.890:14): operation="open" pid=943 parent=835 profile="/usr/sbin/mysqld" requested_mask="r::" denied_mask="r::" fsuid=0 ouid=0 name="/sys/devices/system/cpu/"
type=1503 audit(1305472686.140:15): operation="open" pid=960 parent=959 profile="/usr/sbin/mysqld" requested_mask="r::" denied_mask="r::" fsuid=0 ouid=0 name="/sys/devices/system/cpu/"
type=1503 audit(1305472686.260:16): operation="open" pid=971 parent=970 profile="/usr/sbin/mysqld" requested_mask="r::" denied_mask="r::" fsuid=0 ouid=0 name="/sys/devices/system/cpu/"
em28xx #0: V4L2 device registered as /dev/video0 and /dev/vbi0
usbcore: registered new interface driver snd-usb-audio
usbcore: registered new interface driver em28xx
em28xx driver loaded


本当は音声もキャプチャできるらしいのですが、自分の環境では必要なかったので音声のキャプチャは試していません。

実際に、ffmpegでキャプチャする場合には、こんな感じのコマンドラインでキャプチャできます。

ffmpeg -y -f video4linux2 \
-s vga -r '29.95' -tvstd NTSC -i /dev/video0 \
-aspect '4:3' -r 出力フレームレート \
-vcodec libx264 output.mp4


ここで重要なのは、 "-tvstd NTSC" の部分です。どうもデバイスの初期状態ではPALとして認識しているようなので明示的にNTSCと指定してあげる必要があります。そうしないと表示が乱れます。
よくわかっていないのですが、"-r 29.95"というのもあったほうがよいかもしれません。出力フレームレートは出力形式に合わせて設定してあげましょう。

motion (Linuxの監視カメラ用ソフトウェア)


これはすごいです。Linuxでこんなフリーのソフトウェアがあるというのに驚きました。

motionというのは監視カメラ用ソフトウェアで、

  • 動作を検知し、任意のスクリプトを起動する
  • 動作を検知し、録画を開始する
  • 出力した各フレームにキャプチャ時刻を記録する
  • 簡易ストリーミングサーバー機能を搭載している
  • 複数のカメラに対応している


という立派なソフトウェアです。カメラにアクチュエーターが付属している場合には(おそらくネットワークカメラの類)、カメラの角度も設定することができたりするようです。

ストリーミング機能はmotion Jpegを利用しているようで、iPhoneなどで表示できます。Androidでは表示できませんでした。
PCではもちろん正常に表示できます。

motionの高度な設定


これはおまけ話なのですが、通常は/dev/video0 のデバイスはどれか一つのプロセスのみが利用できるため、motionが動作している場合にはほかのプロセスが利用できません。

が、ループバックデバイスというものを利用すると、motionでキャプチャしているものをループバックデバイスを利用して異なるプロセスが利用できるようにしてくれるらしいです。

マニュアルには「ここに説明書きが書いてるからそんなに難しくないよ」と書かれていますが、実際には何かをコンパイルしたり小難しい設定をしていたので、コンパイルからのインストールに慣れていない人や、Linuxのデバイスがどのようなものか簡単な知識がない人にはちょっと難しいかもしれないです。

PCのスペック


画像を保存する際にCPUを消費するのですが、それ以外ではさほど高スペックのPCは必要ありません。

今回、自分はVIAのEPIA-M10000を使いました。(Mini ITX. CPUはオンボード。動作周波数: 1MHz。シングルコア)。メモリは256MBytesなので、いまどきの環境からするとかなり低スペックですが、監視目的(フレームレートは1~4fps程度で構わない)にはさほど問題はありませんでした。

もっとも、Webカメラで全世界にストリーミング、ということをしたい人はそれなりのスペックのPCを用意したほうがよいかもしれません。

「PCA-DAV2」について友人に書いてもらう。

あなたにとって「PCA-DAV2」とは?

ログインするとワンクリックでキーワードを投稿できます

ログインする 新規登録する

関連したキーワードを持つお気に入り

他の人の「PCA-DAV2」を見る