RICOH THETA API Over USB Cable - (X, Z1, SC2, V, S, SC models)

In order to test libptp, it looks like I need libusb. There is a Ubuntu package for libusb.

craig@linux-silver:~$ sudo apt-get install libusb-1.0-0-dev
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following additional packages will be installed:
  libusb-1.0-doc
The following NEW packages will be installed:
  libusb-1.0-0-dev libusb-1.0-doc
0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded.
Need to get 219 kB of archives.
After this operation, 1,683 kB of additional disk space will be used.
Do you want to continue? [Y/n] 

Install went fine.

I next downloaded libptp source code from Sourceforge.

craig@linux-silver:$ tar xvf libptp2-1.2.0.tar.gz

Extract went fine.

I got this error when I tried ./configure

./configure: line 13153: test: : integer expression expected
configure: error: 
*** You need the 0 line of libusb which is at least 0.1.8.
*** Higher versions might not be compatible! Download and istall
*** libusb version 0.X.X from http://sourceforge.net/projects/libusb/ or
*** use --disable-ptpcam option to build without ptpcam tool.

The easiest thing is to install libusb 0.1.8 and see if it compiles. I compiled and installed libusb 0.1.8.

I then compiled libptp2-1.2.0

It installed in /usr/local/bin

craig@linux-silver:/usr/local/bin$ ls -l ptpcam 
-rwxr-xr-x 1 root root 159904 Jun 29 16:32 ptpcam

When I first tried to run ptpcam, I got this error:

craig@linux-silver:~$ ptpcam
ptpcam: error while loading shared libraries: libptp2.so.1: cannot open shared object file: No such file or directory

I added /usr/local/lib to my LD_LIBRARY_PATH

craig@linux-silver:$ export LD_LIBRARY_PATH=/lib:/usr/lib:/usr/local/lib
craig@linux-silver:$ ptpcam
USAGE: ptpcam [OPTION]

Seems to be working. I’m going to plug in the camera.

Not finding camera

root@linux-silver:~# ptpcam --list-devices
Found no PTP devices

There’s life:

craig@linux-silver:~$ gphoto2 --auto-detect
Model                          Port                                            
----------------------------------------------------------
USB PTP Class Camera           usb:003,009     
craig@linux-silver:~$

root@linux-silver:~# gphoto2 -L -f /store_00010001/DCIM/100RICOH
There are 8 files in folder '/store_00010001/DCIM/100RICOH'.                   
#1     R0010622.JPG               rd  3908 KB 5376x2688 image/jpeg
#2     R0010623.JPG               rd  3862 KB 5376x2688 image/jpeg
#3     R0010624.JPG               rd  3832 KB 5376x2688 image/jpeg

I can also take a picture and download the pictures using the USB cable

craig@linux-silver:~/Documents/tmp$ gphoto2 --capture-image
New file is in location /store_00010001/DCIM/100RICOH/R0010631.JPG on the camera
craig@linux-silver:~/Documents/tmp/img$ gphoto2 -P
Saving file as R0010622.JPG                                                    
Saving file as R0010623.JPG                                                    
Saving file as R0010624.JPG                                                    
Saving file as R0010625.JPG                                                    
Saving file as R0010626.JPG                                                    
Saving file as R0010627.JPG                                                    
Saving file as R0010628.JPG                                                    
Saving file as R0010629.JPG                                                    
Saving file as R0010630.JPG                                                    
Saving file as R0010631.JPG                                                    
craig@linux-silver:~/Documents/tmp/img$ ls
R0010622.JPG  R0010624.JPG  R0010626.JPG  R0010628.JPG  R0010630.JPG
R0010623.JPG  R0010625.JPG  R0010627.JPG  R0010629.JPG  R0010631.JPG
craig@linux-silver:~/Documents/tmp/img$

Capture Image and Download also works

craig@linux-silver:~/Documents/tmp/img$ gphoto2 --capture-image-and-download
New file is in location /store_00010001/DCIM/100RICOH/R0010632.JPG on the camera
Saving file as R0010632.JPG                                                    
Deleting file /store_00010001/DCIM/100RICOH/R0010632.JPG on the camera
craig@linux-silver:~/Documents/tmp/img$

Python Bindings for libgphoto2

install libgphoto-dev

craig@linux-silver:$ sudo apt-get install libgphoto2-dev

Grabbed libgphoto2-python from github

need to install pyrex

craig@linux-silver:~/Documents/Accounts/ricoh/Development/usb/libgphoto2-python$ sudo apt install python-pyrex
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following additional packages will be installed:
  libexpat1-dev libpython-all-dev libpython-dev libpython2.7-dev python-all
  python-all-dev python-dev python2.7-dev
The following NEW packages will be installed:
  libexpat1-dev libpython-all-dev libpython-dev libpython2.7-dev python-all
  python-all-dev python-dev python-pyrex python2.7-dev

running ./configure produced the necessary setup.py

libgphoto2-python$ ls
aclocal.m4      config.status  gphoto-m4        libtool      README
AUTHORS         configure      gp-setup.py      m4           setup.py
auto-aux        configure.ac   gp-setup.py.in   Makefile     setup.py.in
autom4te.cache  COPYING        gptest.py        Makefile.am  test-gp.py
ChangeLog       ctypes-test    INSTALL          Makefile.in  TODO
config.log      gphoto2.pyx    installcheck.mk  NEWS

build and install went smoothly.

$ python setup.py build
$ sudo python setup.py install

I used pydoc gphoto2 to access the docs.

I saved this code snippet into a file called, theta-usb.py

from gphoto2 import *

theta = camera()
theta.init()
folderList = theta.list_folders_in_folder('/')
# print(folderList[0]) #core dump
print(theta.summary)
print(theta.abilities)
theta.capture_image()

The program works over USB, including the ability to take a picture

$ python theta-usb.py 
Manufacturer: Ricoh Company, Ltd.
Model: RICOH THETA S
  Version: 01.42
  Serial Number: 00010093
Vendor Extension ID: 0x6 (1.10)
Functional Mode: 0x8001

Capture Formats: 
Display Formats: Association/Directory, JPEG, Firmware, MP4

Device Capabilities:
    File Download, File Deletion, No File Upload
    Generic Image Capture, 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: 8060403712 (7687 MB)
    Free Space (Bytes): 8002180096 (7631 MB)
    Free Space (Images): 1606

Device Property Summary:
Battery Level(0x5001):(read only) (type=0x2) Range [0 - 100, step 1] value: 100% (100)
Functional Mode(0x5002):(read only) (type=0x4) Enumeration [0,32769] value: 32769
Image Size(0x5003):(readwrite) (type=0xffff) Enumeration [
    '5376x2688',
    '2048x1024'
    ] value: '5376x2688'
Date & Time(0x5011):(readwrite) (type=0xffff) '20160629T203221-0700'
Pre-Capture Delay(0x5012):(readwrite) (type=0x6) Range [0 - 10000, step 1000] value: 0.0s (0)
Perceived Device Type(0xd407):(read only) (type=0x6) 1
White Balance(0x5005):(readwrite) (type=0x4) Enumeration [2,4,32769,32770,6,32800,32771,32772,32773,32774] value: Automatic (2)
Exposure Program Mode(0x500e):(readwrite) (type=0x4) Enumeration [1,2,4,32771] value: P (2)
Exposure Index (film speed ISO)(0x500f):(readwrite) (type=0x4) Enumeration [65535] value: ISO 65535 (65535)
Exposure Bias Compensation(0x5010):(readwrite) (type=0x3) Enumeration [2000,1700,1300,1000,700,300,0,-300,-700,-1000,-1300,-1700,-2000] value: 0.0 stops (0)
Still Capture Mode(0x5013):(readwrite) (type=0x4) Enumeration [1,3,32770] value: Single Shot (1)
Timelapse Number(0x501a):(readwrite) (type=0x4) Range [0 - 9999, step 1] value: 0
Timelapse Interval(0x501b):(readwrite) (type=0x6) Range [8000 - 3600000, step 1000] value: 8000
Audio Volume(0x502c):(readwrite) (type=0x6) Range [0 - 100, step 1] value: 100
Property 0xd006:(read only) (type=0x6) 0
Property 0xd00f:(readwrite) (type=0x8) Enumeration [0] value: 0
Property 0xd801:(readwrite) (type=0xffff) ''
Property 0xd802:(readwrite) (type=0x2) Range [0 - 30, step 1] value: 10
Property 0xd803:(readwrite) (type=0x4) Range [0 - 1800, step 1] value: 600
Property 0xd805:(readwrite) (type=0xffff) 'THETAXS00010093.OSC'
Property 0xd806:(readwrite) (type=0xffff) '00010093'
Property 0xd807:(readwrite) (type=0x2) Enumeration [0,1,6,11] value: 6
Property 0xd808:(read only) (type=0x2) Enumeration [0,1,2] value: 0
Property 0xd809:(read only) (type=0x4) Range [0 - 1499, step 1] value: 0
Property 0xd80a:(read only) (type=0x4) Range [0 - 1500, step 1] value: 0
Property 0xd80b:(readwrite) (type=0x2) Enumeration [0,1,2,3] value: 0
Property 0xd80c:(read only) (type=0x2) Enumeration [0,1,2] value: 2
Property 0xd80d:(read only) (type=0x4) 2718
Property 0xd80e:(readwrite) (type=0x2) Enumeration [0,1] value: 1

Model : USB PTP Class Camera
Status : 1
Port : 4
Operations : 25
File Operations : 10
Folder Operations : 14
USB (vendor/product) : 0x0/0x0
USB class : 0x6/0x1/0x1
Library : /usr/lib/x86_64-linux-gnu/libgphoto2/2.5.9/ptp2
Id : PTP

Unfortunately, I can’t grab the list of files as I get a core dump.