#前提条件
- Raspberry Pi OS ver : Raspbian Buster が正常にインストールされている。
- WiFi接続できている。
- Raspberry Pi Camera Module V2.1
- Raspberry Pi Zero W基板
#インストール
Installation for ARM (Raspberry Pi) に基づいてインストール
###インストールのためのキーを取得し設定する。
$ curl https://www.linux-projects.org/listing/uv4l_repo/lpkey.asc | sudo apt-key add -
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
0 0 0 0 0 0 0 0 --:--:-- 0:00:01 --:--:-- 0
100 26703 100 26703 0 0 11894 0 0:00:02 0:00:02 --:--:-- 11894
OK
###ファイル /etc/apt/sources.list をテキストエディタ(sudo vi /etc/apt/sources.list)などで以下の行を追加
deb https://www.linux-projects.org/listing/uv4l_repo/raspbian/stretch stretch main
###以下のコマンドを実行
$ sudo apt-get update
$ sudo apt-get install uv4l uv4l-raspicam
$ sudo apt-get install uv4l-raspicam-extras
###sudo raspi-config でcameraとI2Cをenableにする。
###rpi-update
$ sudo rpi-update
"DO NOT use 'rpi-update' as part of a regular update process."と表示されるが耐えて続行w
###再起動
$ sudo reboot
###静止画取得のお試し
$ uv4l --driver raspicam --auto-video_nr --width 640 --height 480 --encoding jpeg
<notice> [core] Trying to loading driver 'raspicam' from built-in drivers...
<notice> [core] Loading driver 'raspicam' from external plug-in's...
<notice> [driver] Dual Raspicam & TC358743 Video4Linux2 Driver v1.9.75 built Apr 9 2021
<notice> [driver] Detected camera imx219, 3280x2464
<notice> [driver] Selected format: 640x480, encoding: jpeg, JPEG Still Capture
<notice> [driver] Framerate max. 30 fps
<notice> [core] Device detected!
<warning> [core] Cannot create /dev/video0 because file already exists
<notice> [core] Registering device node /dev/video1
★手順7で「Registering device node /dev/video1」となったので、video1で。ほかの環境だとvideo0になったり、ほかの番号になる可能性あり。
$ dd if=/dev/video1 of=snapshot.jpeg bs=11M count=1
snapshot.jpeg をビューワーでチェック。(私は ラズパイをシャットダウン後、microSDカードをwin10からExt2Fsdでマウントして参照しました。
###web RTCをインストール
$ sudo apt-get install uv4l-webrtc-armv6
###再起動
$ sudo reboot
###IPアドレス確認
$ ifconfig
(中略)
wlan0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.1.xxx netmask 255.255.255.0 broadcast 192.168.1.255
###同じLAN上の端末のブラウザで以下URLで接続
http://192.168.1.xxx:8080/stream/video.h264
★IPアドレスは自分の環境に合わせて記述する。
###備考
以下のようなコマンドで画像サイズを小さくすると、遅延が小さくなったりします。
uv4l --auto-video_nr --driver raspicam --encoding mjpeg --server-option '--port=8080' --width 640 --height 480
###参考URL
RoboPara Raspberry Pi Zero W カメラ映像をリアルタイムでストリーミングする方法 を参考にさせていただきました。2021年4月9日時点では、この「2.UV4Lをインストール」の最初のcurlコマンドが「curl http://~」となってますが、これだとPGP keyが見つからないというエラーになり、インストールできません。2021年4月9日時点では 正しくは
curl https://www.linux-projects.org/listing/uv4l_repo/lpkey.asc
です。(https://~)