実際のところ
BCM2とGNDにそれぞれ線をつなぐ。
操作スクリプトの”button.sh”はこんな塩梅。
#!/bin/bash while : do if [ $(gpio -g read 2) == 0 ]; then fswebcam -r 1920x1080 -S 12 -F 1 image/$(date -Iseconds).png fi printf "." sleep 0.5 done
この例だと撮影画像はimageディレクトリ直下にISO8601規格で"2020-8-17T13:11:43+09:00.png"てな感じのファイル名で保存されます。
ボタンを二回おしたログがこんな感じに。
$ bash button.sh ......--- Opening /dev/video0... Trying source module v4l2... /dev/video0 opened. No input was specified, using the first. --- Capturing frame... Skipping 12 frames... Capturing 1 frames... Captured 13 frames in 0.80 seconds. (16 fps) --- Processing captured image... Writing JPEG image to 'image/2020-8-17T13:11:43+09:00.png'. ....--- Opening /dev/video0... Trying source module v4l2... /dev/video0 opened. No input was specified, using the first. --- Capturing frame... Skipping 12 frames... Capturing 1 frames... Captured 13 frames in 0.80 seconds. (16 fps) --- Processing captured image... Writing JPEG image to 'image/2020-8-17T13:11:49+09:00.png'. ....