Picture Transfer Protocol(PTP)を利用すれば画像の転送はもちろん、直接カメラを操作しなくてもPCなどからカメラの操作を行えます。
PTPの仕様を理解するために下記を実施しました(未完です)。
目的
PTPの仕様の理解を深める。
方法
実際のやりとりの内容と照らし合わせながら仕様を確認する。
やりとりの内容はgphoto2のdebug出力で確認できそうとのこと。
gphoto2:http://gphoto.org/proj/gphoto2/
仕様は下記を参考にする(予定)。
概要:http://books-nekoya.jp/Programming/PTP/ptp.html
詳細:https://people.ece.cornell.edu/land/courses/ece4760/FinalProjects/f2012/jmv87/site/files/pima15740-2000.pdf
結果
1. 確認環境
PCはMacを使用した。
$ sw_vers
ProductName: Mac OS X
ProductVersion: 10.10.5
BuildVersion: 14F27
カメラは初代THETAを使用した(USB接続)。
2. gphoto2のインストール
brewでインストールした。
brew install gphoto2
動作確認のため、機器情報を表示させようとしたところエラーが発生した。
$ gphoto2 --auto-detect
Model Port
----------------------------------------------------------
USB PTP Class Camera usb:020,010
$ 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') ***
For debugging messages, please use the --debug option.
Debugging messages may help finding a solution to your problem.
If you intend to send any error or debug messages to the gphoto
developer mailing list <gphoto-devel@lists.sourceforge.net>, please run
gphoto2 as follows:
env LANG=C gphoto2 --debug --debug-logfile=my-logfile.txt --list-config
Please make sure there is sufficient quoting around the arguments.
下記URLを参考に、PTPCameraのプロセスをkillした。
https://sourceforge.net/p/gphoto/mailman/message/27841914/
$ ps axuwww | grep "PTPCamera" | grep -v "grep"
**** 9615 0.0 0.2 2548124 16164 ?? S 9:47PM 0:00.15 /System/Library/Image Capture/Devices/PTPCamera.app/Contents/MacOS/PTPCamera
$ sudo kill -9 9615
エラーが解消され、動作確認ができた。
$ gphoto2 --auto-detect
Model Port
----------------------------------------------------------
USB PTP Class Camera usb:020,010
$ gphoto2 --summary
Camera summary:
Manufacturer: Ricoh Company, Ltd.
Model: RICOH THETA
Version: 01.30
Vendor Extension ID: 0x6 (1.10)
Capture Formats:
Display Formats: Association/Directory, JPEG, Firmware
Device Capabilities:
File Download, File Deletion, No File Upload
No Image Capture, No Open Capture, No vendor specific capture
Storage Devices Summary:
store_00010001:
StorageDescription: None
VolumeLabel: None
Storage Type: Builtin RAM
Filesystemtype: Digital Camera Layout (DCIM)
Access Capability: Read-Write
Maximum Capability: 4027580416 (3841 MB)
Free Space (Bytes): 3969750016 (3785 MB)
Free Space (Images): 1211
Device Property Summary:
Battery Level(0x5001):(read only) (type=0x2) Range [0 - 100, step 1] value: 100% (100)
Date & Time(0x5011):(read only) (type=0xffff) '20130101T002039'
Perceived Device Type(0xd407):(read only) (type=0x6) 1
2. やりとりの表示
debug情報は標準エラー出力で出力される。
内容を確認したところ、下記のgrepで抽出した表示で各やりとりの概要と内容が確認できると思われる。
$ gphoto2 --summary --debug 2>&1 > /dev/null | grep -e "PTP_OC" -e "^[0-9][0-9][0-9][0-9] "
0.269657 ptp_usb_sendreq (2): Sending PTP_OC 0x1002 (Open session) request...
0000 10 00 00 00 01 00 02 10-00 00 00 00 01 00 00 00 ................
0.270148 ptp_usb_getresp (2): Reading PTP_OC 0x1002 (Open session) response...
0000 0c 00 00 00 03 00 01 20-00 00 00 00 ....... ....
0.270418 ptp_usb_sendreq (2): Sending PTP_OC 0x1001 (Get device info) request...
0000 0c 00 00 00 01 00 01 10-01 00 00 00 ............
0.270640 ptp_usb_getdata (2): Reading PTP_OC 0x1001 (Get device info) data...
0000 b5 00 00 00 02 00 01 10-01 00 00 00 64 00 06 00 ............d...
0010 00 00 6e 00 00 00 00 0e-00 00 00 01 10 02 10 03 ..n.............
0020 10 04 10 05 10 06 10 07-10 08 10 09 10 0a 10 0b ................
0030 10 14 10 15 10 01 90 00-00 00 00 03 00 00 00 01 ................
0040 50 11 50 07 d4 00 00 00-00 03 00 00 00 01 30 01 P.P...........0.
0050 38 02 b8 14 52 00 69 00-63 00 6f 00 68 00 20 00 8...R.i.c.o.h. .
0060 43 00 6f 00 6d 00 70 00-61 00 6e 00 79 00 2c 00 C.o.m.p.a.n.y.,.
0070 20 00 4c 00 74 00 64 00-2e 00 00 00 0c 52 00 49 .L.t.d......R.I
0080 00 43 00 4f 00 48 00 20-00 54 00 48 00 45 00 54 .C.O.H. .T.H.E.T
0090 00 41 00 00 00 06 30 00-31 00 2e 00 33 00 30 00 .A....0.1...3.0.
0.270953 ptp_usb_getresp (2): Reading PTP_OC 0x1001 (Get device info) response...
0000 0c 00 00 00 03 00 01 20-01 00 00 00 ....... ....
0.271510 print_debug_deviceinfo (2): 0x9001 (Unknown PTP_OC)
0.271699 ptp_usb_sendreq (2): Sending PTP_OC 0x1007 (Get object handles) request...
0000 18 00 00 00 01 00 07 10-02 00 00 00 ff ff ff ff ................
0010 00 00 00 00 ff ff ff ff- ........
0.271931 ptp_usb_getdata (2): Reading PTP_OC 0x1007 (Get object handles) data...
0000 14 00 00 00 02 00 07 10-02 00 00 00 01 00 00 00 ................
0010 00 00 00 80 - ....
0.272348 ptp_usb_getresp (2): Reading PTP_OC 0x1007 (Get object handles) response...
0000 0c 00 00 00 03 00 01 20-02 00 00 00 ....... ....
0.272602 ptp_usb_sendreq (2): Sending PTP_OC 0x1004 (Get storage IDs) request...
0000 0c 00 00 00 01 00 04 10-03 00 00 00 ............
0.272872 ptp_usb_getdata (2): Reading PTP_OC 0x1004 (Get storage IDs) data...
0000 14 00 00 00 02 00 04 10-03 00 00 00 01 00 00 00 ................
0010 01 00 01 00 - ....
0.273151 ptp_usb_getresp (2): Reading PTP_OC 0x1004 (Get storage IDs) response...
0000 0c 00 00 00 03 00 01 20-03 00 00 00 ....... ....
0.273377 ptp_usb_sendreq (2): Sending PTP_OC 0x1007 (Get object handles) request...
0000 18 00 00 00 01 00 07 10-04 00 00 00 01 00 01 00 ................
0010 00 00 00 00 ff ff ff ff- ........
0.273567 ptp_usb_getdata (2): Reading PTP_OC 0x1007 (Get object handles) data...
0000 14 00 00 00 02 00 07 10-04 00 00 00 01 00 00 00 ................
0010 00 00 00 80 - ....
0.273931 ptp_usb_getresp (2): Reading PTP_OC 0x1007 (Get object handles) response...
0000 0c 00 00 00 03 00 01 20-04 00 00 00 ....... ....
0.274119 ptp_usb_sendreq (2): Sending PTP_OC 0x1004 (Get storage IDs) request...
0000 0c 00 00 00 01 00 04 10-05 00 00 00 ............
0.274352 ptp_usb_getdata (2): Reading PTP_OC 0x1004 (Get storage IDs) data...
0000 14 00 00 00 02 00 04 10-05 00 00 00 01 00 00 00 ................
0010 01 00 01 00 - ....
0.274538 ptp_usb_getresp (2): Reading PTP_OC 0x1004 (Get storage IDs) response...
0000 0c 00 00 00 03 00 01 20-05 00 00 00 ....... ....
0.274725 ptp_usb_sendreq (2): Sending PTP_OC 0x1005 (Get storage info) request...
0000 10 00 00 00 01 00 05 10-06 00 00 00 01 00 01 00 ................
0.274933 ptp_usb_getdata (2): Reading PTP_OC 0x1005 (Get storage info) data...
0000 28 00 00 00 02 00 05 10-06 00 00 00 03 00 03 00 (...............
0010 00 00 00 00 10 f0 00 00-00 00 00 94 9d ec 00 00 ................
0020 00 00 bb 04 00 00 00 00- ........
0.275084 ptp_usb_getresp (2): Reading PTP_OC 0x1005 (Get storage info) response...
0000 0c 00 00 00 03 00 01 20-06 00 00 00 ....... ....
0.275256 ptp_usb_sendreq (2): Sending PTP_OC 0x1001 (Get device info) request...
0000 0c 00 00 00 01 00 01 10-07 00 00 00 ............
0.275419 ptp_usb_getdata (2): Reading PTP_OC 0x1001 (Get device info) data...
0000 b5 00 00 00 02 00 01 10-07 00 00 00 64 00 06 00 ............d...
0010 00 00 6e 00 00 00 00 0e-00 00 00 01 10 02 10 03 ..n.............
0020 10 04 10 05 10 06 10 07-10 08 10 09 10 0a 10 0b ................
0030 10 14 10 15 10 01 90 00-00 00 00 03 00 00 00 01 ................
0040 50 11 50 07 d4 00 00 00-00 03 00 00 00 01 30 01 P.P...........0.
0050 38 02 b8 14 52 00 69 00-63 00 6f 00 68 00 20 00 8...R.i.c.o.h. .
0060 43 00 6f 00 6d 00 70 00-61 00 6e 00 79 00 2c 00 C.o.m.p.a.n.y.,.
0070 20 00 4c 00 74 00 64 00-2e 00 00 00 0c 52 00 49 .L.t.d......R.I
0080 00 43 00 4f 00 48 00 20-00 54 00 48 00 45 00 54 .C.O.H. .T.H.E.T
0090 00 41 00 00 00 06 30 00-31 00 2e 00 33 00 30 00 .A....0.1...3.0.
0.275639 ptp_usb_getresp (2): Reading PTP_OC 0x1001 (Get device info) response...
0000 0c 00 00 00 03 00 01 20-07 00 00 00 ....... ....
0.275789 ptp_usb_sendreq (2): Sending PTP_OC 0x1014 (Get device property description) request...
0000 10 00 00 00 01 00 14 10-08 00 00 00 01 50 00 00 .............P..
0.275964 ptp_usb_getdata (2): Reading PTP_OC 0x1014 (Get device property description) data...
0000 17 00 00 00 02 00 14 10-08 00 00 00 01 50 02 00 .............P..
0010 00 64 64 01 00 64 01 - .dd..d.
0.276117 ptp_usb_getresp (2): Reading PTP_OC 0x1014 (Get device property description) response...
0000 0c 00 00 00 03 00 01 20-08 00 00 00 ....... ....
0.276371 ptp_usb_sendreq (2): Sending PTP_OC 0x1014 (Get device property description) request...
0000 10 00 00 00 01 00 14 10-09 00 00 00 11 50 00 00 .............P..
0.276549 ptp_usb_getdata (2): Reading PTP_OC 0x1014 (Get device property description) data...
0000 54 00 00 00 02 00 14 10-09 00 00 00 11 50 ff ff T............P..
0010 00 10 32 00 30 00 31 00-33 00 30 00 31 00 30 00 ..2.0.1.3.0.1.0.
0020 31 00 54 00 30 00 30 00-30 00 30 00 30 00 30 00 1.T.0.0.0.0.0.0.
0030 00 00 10 32 00 30 00 31-00 33 00 30 00 31 00 30 ...2.0.1.3.0.1.0
0040 00 31 00 54 00 30 00 30-00 33 00 31 00 30 00 34 .1.T.0.0.3.1.0.4
0050 00 00 00 00 - ....
0.276807 ptp_usb_getresp (2): Reading PTP_OC 0x1014 (Get device property description) response...
0000 0c 00 00 00 03 00 01 20-09 00 00 00 ....... ....
0.276999 ptp_usb_sendreq (2): Sending PTP_OC 0x1014 (Get device property description) request...
0000 10 00 00 00 01 00 14 10-0a 00 00 00 07 d4 00 00 ................
0.277225 ptp_usb_getdata (2): Reading PTP_OC 0x1014 (Get device property description) data...
0000 1a 00 00 00 02 00 14 10-0a 00 00 00 07 d4 06 00 ................
0010 00 00 00 00 00 01 00 00-00 00 ..........
0.277366 ptp_usb_getresp (2): Reading PTP_OC 0x1014 (Get device property description) response...
0000 0c 00 00 00 03 00 01 20-0a 00 00 00 ....... ....
0.277693 ptp_usb_sendreq (2): Sending PTP_OC 0x1003 (Close session) request...
0000 0c 00 00 00 01 00 03 10-0b 00 00 00 ............
0.278883 ptp_usb_getresp (2): Reading PTP_OC 0x1003 (Close session) response...
0000 0c 00 00 00 03 00 01 20-0b 00 00 00 ....... ....
3. やりとりの内容と仕様の照らし合わせ
T.B.D
まとめ
T.B.D