見出し画像

gPhoto2、最強のカメラコントロール

おそらく、Raspberry Pi(ラズパイ)を難なく使えて天体写真を撮る人にとって、最強のソフトウェアと言えるかもしれません。
2年ぐらい前にも使ったんですが、今回、改めて使うために再セットアップしたので、使い方をまとめました。
(2022/10/7、加筆修正)

インストール

wget https://raw.githubusercontent.com/gonzalo/gphoto2-updater/master/gphoto2-updater.sh && wget https://raw.githubusercontent.com/gonzalo/gphoto2-updater/master/.env && chmod +x gphoto2-updater.sh && sudo ./gphoto2-updater.sh

メニューで
 1) Install last development version
 2) Install last stable release (libgphoto 2.5.30; gphoto 2.5.28)
 3) Quit
と表示されます。
安定版をインストールしたいので"2"を選択
あとは、待つだけです。(結構待ちます。)

This version of gphoto2 is using the following software versions and options:
gphoto2         2.5.28         gcc, popt(m), exif, no cdk, no aa, no jpeg, no readline
libgphoto2      2.5.27         standard camlibs, gcc, ltdl, EXIF
libgphoto2_port 0.12.0         iolibs: disk ptpip serial usb1 usbdiskdirect usbscsi, gcc, ltdl, EXIF, USB, serial without lockin

と表示されればインストール完了です。

バージョン確認

インストールされたのか確認するために、バージョンを確認します。

$ gphoto2 --version
gphoto2 2.5.28

Copyright (c) 2000-2021 Marcus Meissner and others

gphoto2 comes with NO WARRANTY, to the extent permitted by law. You may
redistribute copies of gphoto2 under the terms of the GNU General Public
License. For more information about these matters, see the files named COPYING.

This version of gphoto2 is using the following software versions and options:
gphoto2         2.5.28         gcc, popt(m), exif, no cdk, no aa, no jpeg, no readline
libgphoto2      2.5.27         standard camlibs, gcc, ltdl, EXIF
libgphoto2_port 0.12.0         iolibs: disk ptpip serial usb1 usbdiskdirect usbscsi, gcc, ltdl, EXIF, USB, serial without locking

カメラ接続確認

カメラとラズパイをUSBケーブルで接続し、カメラの電源を入れます。

すると"/var/log/messages"に以下のようにメッセージが表示されます。

Oct  7 11:17:39 raspberrypi kernel: [  180.380517] usb 1-1.3: new high-speed USB device number 4 using dwc_otg
Oct  7 11:17:39 raspberrypi kernel: [  180.511590] usb 1-1.3: New USB device found, idVendor=04a9, idProduct=3281, bcdDevice= 0.02
Oct  7 11:17:39 raspberrypi kernel: [  180.511630] usb 1-1.3: New USB device strings: Mfr=1, Product=2, SerialNumber=0
Oct  7 11:17:39 raspberrypi kernel: [  180.511650] usb 1-1.3: Product: Canon Digital Camera
Oct  7 11:17:39 raspberrypi kernel: [  180.511666] usb 1-1.3: Manufacturer: Canon Inc.
Oct  7 11:17:39 raspberrypi mtp-probe: checking bus 1, device 4: "/sys/devices/platform/soc/3f980000.usb/usb1/1-1/1-1.3"
Oct  7 11:17:39 raspberrypi mtp-probe: bus: 1, device: 4 was not an MTP device
Oct  7 11:17:39 raspberrypi mtp-probe: checking bus 1, device 4: "/sys/devices/platform/soc/3f980000.usb/usb1/1-1/1-1.3"
Oct  7 11:17:39 raspberrypi mtp-probe: bus: 1, device: 4 was not an MTP device

サマリ情報表示

$ gphoto2 --summary
カメラのサマリ:                                                                
Manufacturer: Canon.Inc
Model: Canon EOS 5D Mark IV
  Version: x-x.x.x
  Serial Number: xxxxxxxxxxxxxxxxxxxx
Vendor Extension ID: xxx (1.0)
Vendor Extension Description: 

Capture Formats: JPEG
Display Formats: Association/Directory, Script, DPOF, MS AVI, MS Wave, JPEG, CRW, Unknown(b103), Unknown(bf02), Defined Type, Unknown(b104), Unknown(b105)

Device Capabilities:
	File Download, File Deletion, File Upload
	No Image Capture, No Open Capture, Canon EOS Capture, Canon EOS Capture 2
	Canon Wifi support

Storage Devices Summary:

Device Property Summary:
Property 0xd402:(read only) (type=0xffff) 'Canon EOS 5D Mark IV'
Property 0xd407:(read only) (type=0x6) 1
Property 0xd406:(readwrite) (type=0xffff) 'Unknown Initiator'
Property 0xd303:(read only) (type=0x2) 1
Battery Level(0x5001):(read only) (type=0x2) Enumeration [100,0,75,0,50] value: 70% (70)

シャッター押下&カメラ内保存

gphoto2 --capture-image

このコマンドだと、カメラのメモリーカード内に画像が残ります。

シャッター押下&ラズパイ内ダウンロード

gphoto2 --capture-image-and-download

このコマンドだと、カメラのメモリーカード内に画像は残らずラズパイにダウンロードされます。(正確にはダウンロード後にメモリーカードから削除される)

ダウンロード先はコマンドを実行したディレクトリになります。

絞りリスト取得&セット

gphoto2 --get-config aperture

設定可能な絞りのリストが表示されます。

gphoto2 --set-config aperture="8"

これで、絞りを"8"に設定します。

シャッタースピードリスト取得&セット

gphoto2 --get-config shutterspeed

設定可能な絞りのリストが表示されます。

gphoto2 --set-config shutterspeed="1/1000"

これで、シャッタースピードを"1/1000"に設定します。

ISOリスト取得&セット

gphoto2 --get-config iso

設定可能な絞りのリストが表示されます。

gphoto2 --set-config iso="400"

これで、シャッタースピードを"400"に設定します。

Canonカメラで最初に必要

gphoto2 --set-config-index capturetarget=1

EOSはデフォルトで画像の格納先が内部RAMになっているようなので、電源を消したら画像も消去されちゃいます。
格納先をメモリカードに切り替えてデータを残すようにします。

EOS 50Dを接続して動かない場合

EOS 50DやEOS 20Dなど古いEOSを接続した場合、gPhoto2が正常に動作しませんでした。
どうやら、バックグラウンドでgvfs-gphoto2-volume-monitorプロセスが存在するため、干渉しているようです。
なので、当該プロセスを以下の要領で殺します。

ps aux | grep gphoto

を実行し、
---
pi         726  0.0  0.8  40712  8092 ?        Ssl  10:23   0:00 /usr/lib/gvfs/gvfs-gphoto2-volume-monitor
pi        1313  0.0  1.0 113008 10204 ?        Sl   10:54   0:00 /usr/lib/gvfs/gvfsd-gphoto2 --spawner :1.4 /org/gtk/gvfs/exec_spaw/1
pi        1449  0.0  0.0   3916   560 pts/0    S+   11:00   0:00 grep --color=auto gphoto
---
から、

kill -9 726
kill -9 1313 

を実行します。
-------

スクリプトを組んでインターバル撮影や定期的な撮影、月食や日食の進行に合わせての複数露出での観測などなど、使い方はいろいろです。

ラズパイはモバイルバッテリーで十分動作しますので、電源問題に悩まされることもありませんし、デジイチとスマホをWi-Fiで接続しても不安定な通信状態に悩まされることもありません。

ラズパイも5000円程度で買え、セットアップ方法も驚くほど簡単になったので、是非お試しあれ。


宜しければサポートをお願い致します。ご厚意は天文ボランティア活動の資金とさせて頂きます。 これからも星空に興味を持っていただけるような記事を書きたいと思っています。