MacとgPhoto2でEOS Kiss X4を操作してみる

www.moyashi-koubou.com

この記事がすごく良い内容でした!この中でgPhoto2なるカメラをターミナルから操作できるライブラリがあるということを知ったのでMacでも試してみました。

Macの場合だとインストールはbrewで。

$ brew install gphoto2

カメラをUSBで繋いで gphoto2 --auto-detect で繋いだカメラが見つかります。

$ gphoto2 --auto-detect
Model                          Port
----------------------------------------------------------
Canon EOS 550D                 usb:020,028

ここまで順調!順調!ときていたのですがここでエラーが...

$ gphoto2 --summary

*** Error ***
An error occurred in the io-library ('Could not claim the USB device'): Could not claim interface 0 (No such file or directory). Make sure no other program (MacOS PTPCamera service) or kernel module (such as sdc2xx, stv680, spca50x) is using the device and you have read/write access to the device.
*** Error (-53: 'Could not claim the USB device') ***

gphoto2 --summary でカメラの情報がでるはずだったのですが。

解決方法としては、このカメラを繋いだ状態でPTPCameraのプロセスをkillします。

$ ps axuwww | grep "PTPCamera" | grep -v "grep"
8961   0.0  0.1  2529484  12392   ??  S    12:48AM   0:00.16 /System/Library/Image Capture/Devices/PTPCamera.app/Contents/MacOS/PTPCamera
$ kill -9 8961

そしてもう一度gphoto2 --summaryを実行するとちゃんとカメラの情報が出てきます。

$ gphoto2 --summary
Camera summary:
Manufacturer: Canon Inc.
Model: Canon EOS Kiss X4
  Version: 3-1.0.6
  Serial Number: xxxxxxxxxxxxxxxxxxx
Vendor Extension ID: 0xb (2.0)

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

Device Capabilities:
        File Download, File Deletion, File Upload
        No Image Capture, No Open Capture, Canon EOS Capture, Canon EOS Shutter Button
...

この状態で以下のコマンドを実行すると写真が撮影できました!

$ gphoto2 --capture-image-and-download --filename=/tmp/picture.jpg

あとは他にも設定を変えられたりするのですが、それは以下の記事がすごく詳しかったです。

www.moyashi-koubou.com

こんな感じで特に使いたいことがあるわけではないのですが、勢いに任せてターミナルから撮影するまでやってみました。