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

To simplify things I’ve written a script that will convert shutter speeds to the hex format needed for ptpcam -R. Here’s an example.

$ ./shutterspeed_to_hex.sh -s 0.25
HEX Shutter speed: \x01\x00\x00\x00\x04\x00\x00\x00

Or send the output to a bin file for ptpcam.

$ ./shutterspeed_to_hex.sh -s 0.25 -b shutter.bin
$ ptpcam -R 0x1016,0xd00f,0,0,0,0,shutter.bin
2 Likes

This is awesome. Thank you.

November featured developer!

Hi,
Thank you for this great tutorial.
Maybe I’ve missed something, but how did you solve the problem that ptpcam cannot find the device?
I’ve followed your steps, and now I am able to find the device using gphoto2 --auto-detect, and execute the command gphoto2 -L -f /store_00010001/DCIM/100RICOH and get the list of files. But I cannot capture an image using the gphoto2 --capture-image command. Nor can I get the device info using ptpcam -i.
Another question is, how do you connect the camera to your computer? I tried connect it via usb, but the blue light automatically turned off. Am I supposed to connect it in live stream mode?

The blue light needs to be on. The camera should be in image or video mode not streaming. Your computer may be auto-mounting the camera. Unmounted the camera and try the test. What OS version are you using?

Remove gvfs-backend from your system.

It’s running Ubuntu 16.04, and it does auto-mount the camera.
However, I tried unmount and remove gvfs-backends. It’s still not working.
Only the power led is on, red. Perhaps it has something to do with the usb port?

The light should be blue. There are pictures of what the camera needs to look like if you scroll up in this thread. I’m not in front of my computer now. Did you try plugging the theta in when it is off then turning it on to image mode while it is plugged in? I can try to replicate this problem tomorrow. Most people are using Ubuntu or raspian. I think you’ll get it working once you overcome the connection problem.

Turn the THETA on and then connect it.

Here is the THETA connected to Ubuntu 16.10. The front blue dot and the camera icon are blue.

The side button is red.

craig@linux-cube:~$ lsusb
Bus 002 Device 002: ID 8087:8000 Intel Corp. 
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 002: ID 8087:8008 Intel Corp. 
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 003 Device 003: ID 05ca:0366 Ricoh Co., Ltd 

Detect Device with gphoto2

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

Taking Picture with gphoto2

craig@linux-cube:~$ gphoto2 --capture-image
New file is in location /store_00010001/DCIM/100RICOH/R0011887.JPG on the camera
craig@linux-cube:~$ 

Download All Images and Videos

craig@linux-cube:~$ gphoto2 -P
Saving file as R0011758.JPG                                                    
Saving file as R0011759.JPG                                                    
Saving file as R0011761.JPG                                                    
Saving file as R0011763.JPG                                                    
Saving file as R0011764.JPG                                                    
Saving file as R0011765.JPG                                                    
Saving file as R0011766.JPG                                                    
Saving file as R0011767.JPG                                                    
Saving file as R0011768.MP4                                                    
Saving file as R0011771.JPG                                                    
Saving file as R0011772.JPG                                                    
Saving file as R0011773.JPG                                                    
Saving file as R0011774.JPG  

Take Picture, Download to Ubuntu, Delete from Camera

craig@linux-cube:~/Development/ricoh/usb-api$ gphoto2 --capture-image-and-download
New file is in location /store_00010001/DCIM/100RICOH/R0011888.JPG on the camera
Saving file as R0011888.JPG                                                    
Deleting file /store_00010001/DCIM/100RICOH/R0011888.JPG on the camera
craig@linux-cube:~/Development/ricoh/usb-api$ 

List Files and Folders on THETA

craig@linux-cube:~/Development/ricoh/usb-api$ gphoto2 --list-files
There is no file in folder '/'.                                                
There is no file in folder '/store_00010001'.
There is no file in folder '/store_00010001/DCIM'.
There are 114 files in folder '/store_00010001/DCIM/100RICOH'.
#1     R0011758.JPG               rd  3904 KB 5376x2688 image/jpeg
#2     R0011759.JPG               rd  3956 KB 5376x2688 image/jpeg
#3     R0011761.JPG               rd  3869 KB 5376x2688 image/jpeg
#4     R0011763.JPG               rd  3903 KB 5376x2688 image/jpeg
#5     R0011764.JPG               rd  3939 KB 5376x2688 image/jpeg
#6     R0011765.JPG               rd  3829 KB 5376x2688 image/jpeg
#7     R0011766.JPG               rd  3858 KB 5376x2688 image/jpeg
#8     R0011767.JPG               rd  3885 KB 5376x2688 image/jpeg
#9     R0011768.MP4               rd 50123 KB 1920x1080 video/mp4

Check Battery Level of THETA

craig@linux-cube:~/Development/ricoh/usb-api$ gphoto2 --get-config=batterylevel
Label: Battery Level                                                           
Type: TEXT
Current: 67%
craig@linux-cube:~/Development/ricoh/usb-api$ 

Check whitebalance of THETA

craig@linux-cube:~/Development/ricoh/usb-api$ gphoto2 --get-config=whitebalance

Label: WhiteBalance                                                            
Type: RADIO
Current: Automatic
Choice: 0 Automatic
Choice: 1 Daylight
Choice: 2 Unknown value 8001
Choice: 3 Unknown value 8002
Choice: 4 Tungsten
Choice: 5 Unknown value 8020
Choice: 6 Unknown value 8003
Choice: 7 Unknown value 8004
Choice: 8 Unknown value 8005
Choice: 9 Unknown value 8006
Choice: 10 Unknown value 8007
craig@linux-cube:~/Development/ricoh/usb-api$ 

Get Capture Mode

craig@linux-cube:~/Development/ricoh/usb-api$ gphoto2 --get-config=capturemode
Label: Still Capture Mode                                                      
Type: RADIO
Current: Single Shot
Choice: 0 Single Shot
Choice: 1 Timelapse
Choice: 2 Unknown value 8002
Choice: 3 Unknown value 8003
Choice: 4 Unknown value 8004

Set Capture Mode to Timelapse

craig@linux-cube:~/Development/ricoh/usb-api$ gphoto2 --set-config capturemode=1
craig@linux-cube:~/Development/ricoh/usb-api$ gphoto2 --get-config capturemode
Label: Still Capture Mode                                                      
Type: RADIO
Current: Timelapse
Choice: 0 Single Shot
Choice: 1 Timelapse
Choice: 2 Unknown value 8002

Show Info on Specific Image

craig@linux-cube:~/Development/ricoh/usb-api$ gphoto2 --show-info 2

Information on file 'R0011759.JPG' (folder '/store_00010001/DCIM/100RICOH'):   
File:
  Mime type:   'image/jpeg'
  Size:        4050247 byte(s)
  Width:       5376 pixel(s)
  Height:      2688 pixel(s)
  Permissions: read/delete
  Time:        Tue Jul 12 18:45:49 2016
Thumbnail:
  Mime type:   'image/jpeg'
  Size:        3258 byte(s)
  Width:       160 pixel(s)
  Height:      120 pixel(s)
Audio data:
  None available.
craig@linux-cube:~/Development/ricoh/usb-api$
1 Like

Thank you.
It turns out the problem is an outdated firmware. After upgrading, I can now run the gphoto2 commands you have listed, although ptpcam is still not able to connect to the camera.

2 Likes

Great news!!

Thank you for sharing your solution. I forgot to mention that the camera firmware needs to be 01.42 or above. This information will help other people as well.

Additional information for people that need to upgrade firmware:

Regarding ptpcam, I need to jump on some other work right now and can’t fully test it today as the original test configuration I used is on a different machine and I’ll need to compile ptpcam on the machine I used for the gphoto2 test. I had ptpcam working reliably on different Ubuntu test machines and on a Raspberry Pi several months ago.

Here’s one tip.

Community member @orikoon supplied this information:

I'm using Ubuntu 14.10 and libptp2 1.2.0. Actually, my project does not use the video features but I tested the following command and it worked nicely.

First, To set video mode :

ptpcam --set-property=0x5013 --val=0x8002
And start shooting :

ptpcam -R 0x101C
Finally, stop shooting :

ptpcam -R 0x1018,0xFFFFFFFF
I hope this may help you!

https://developers.theta360.com/en/docs/v2/usb_reference/operation/initiate_open_capture.html1
https://developers.theta360.com/en/docs/v2/usb_reference/operation/terminate_open_capture.html

I’ve used ptpcam on 16.04, but if you’re having problems, you may want to use ubuntu 14.04 or 14.10 (which is the exact configuration that Orikoon was using) on a test machine.

1 Like

Hi all, I’m currently running the ricoh S in interval mode plugged into a large USB battery pack, but it seems to turn off on its own randomly between 4 and 8 hours. It never runs out of battery or space for images, so I’m wondering if it’s over heating or something. It sounds like several people have had luck with longer term recording with the Pi. thanks!

There are two very good long-term usage examples with the USB API.

Photosphere by Koen Hufkens has been going for months (I think)

tlapser by Jason Charcalla has been well-tested.

I you want to have it running for months to take several hundred thousand or more pictures, note that there is a problem with unattended remote locations. The USB API does not support turning on the RICOH THETA S. Thus, if there is a power outage, you’ll have to drive to the remote location and turn the camera on. We’ve submitted this feature request to RICOH so that the camera can be used for remote surveillance and image data acquisition.

I’m surprised that the camera turns off after 4 to 8 hours when you have it plugged into the battery. Do you have a battery that is outputting 1.5 amps? You may be able to stabilize the camera by using a battery with higher amperage output. You can test this theory before you spend any money by plugging the camera into a wall charger (like your phone or tablet or kindle charger) that is capable of putting out 1.5 amps and see if the camera turns off overnight. I suspect that the battery you are using is not sufficient enough to keep the battery charged.

I’m interested to learn more about your usage.

If you go with the USB route (which is what I would do), suggest you read through the thread and consider running an earlier version if you have problems with libptp.

I did my tests with both a raspberry pi running Jessie and an Ubuntu laptop. I ran into a problem with stopping video. Another community member mentioned that they had the video stop working with Ubuntu 14.04. That’s the reason I was thinking of testing Wheezy (older version of Raspian). The raspian archive is here

2 Likes

thanks! I’m just trying to last through an 8 hour shift, so I don’t need to pull the images yet, but I’ll try out the Pi soon. I’m using this power pack, which has a 1A and 2A outlet. I’ll make sure I’m using the 2A output. https://www.monoprice.com/Product?p_id=13083&gclid=Cj0KEQiAiMHEBRC034nx2ImB1J0BEiQA-r7ctl-4V45FfEn1joeHhDyaPNg1dgMFG1Mw46aumlYFQzMaAi-d8P8HAQ

Right now we’re using several Ricohs in a factory to record equipment being built, but we’d also like to use it to capture events, like conferences and trade shows. It’s been pretty finicky for us, turning off sometimes even after an hour, but other times lasting 8 hours. Still haven’t figured out what the root cause is… the internal battery always has a full charge, and there’s almost always still space left. I should probably try upgrading the firmware. I’m on 1.10.0.

I had read about the inability to turn on via USB… I’m tempted to take it apart and automate the power switch :slight_smile:

1 Like

Hi

i think you have to update your Firmware check this link

Regards Svendus

1 Like

Agree with @svendus, you should try a firmware update

Instructions on upgrading your firmware.

The most recent version of the firmware is 01.82. See release notes.

After you upgrade the firmware, please confirm that you have disabled offDelay and sleepDelay.

Please let us know if you’re comfortable using the API, either with a Bash script, curl, Python or other language/tool.

Here’s a video I made on setting the offDelay with no coding. View on YouTube in full screen.

I have several more ideas for you to consider. For example, have you considered using live streaming to disk at 1080? This is lower resolution than the images, but it might be usable in your application. Information is here.

Let us know where you stand after the firmware upgrade and verifying that offDelay and sleepDelay are disabled (tell us the value you used).

1 Like

Thanks again! I’ve got the firmware updated and am doing a test now. We do need the full resolution of the stills for most of our applications.

I’ll also test out disabling the offDelay and sleepDelay, although it seems strange that I’d get a variable performance due to a setting. But doesn’t hurt to double check. I really appreciate all the suggestions.

yes, I agree that part is bothersome. If it consistently went off after a certain amount of time, I’d feel better about us narrowing in the problem. It seems like the original idea of the power amperage could be the source of the problem.

Is it possible that the camera is dropping WiFi signal with the controller (maybe your laptop)? If the WiFi signal dropped, then the sleepDelay would kick in after 20 minutes (I think this is the default). If you’re having WiFi issues, you can try and rotate the WiFi channel of the camera with _wlanChannel. For the test, you can also put the laptop right next to the THETA S (like a foot away).

I would also try to use a Raspberry Pi with the USB API. I realize that you need to buy that part first and it’s not as clean of a physical solution, but the transfer speed over USB is great and you can power the THETA over the same USB cable.

Maybe in the best scenario, you get both working and have a few options for the people taking pictures. I’ve heard of people using both WiFi and USB APIs for timelapse over a few days.

1 Like

So my last test with the 2A output and new firmware lasted about 5 hours. At that point, the Camera Status LED was blinking red, which I believe indicates a problem in the camera. https://theta360.com/en/support/manual/s/content/prepare/prepare_02.html

There was still plenty of space on the SD card and I believe battery left. I had it on 14s interval. Also, I disconnected the WiFi almost immediately after starting the interval.

I’m going to try a test powered off a Pi USB port and report back. I also have not tried disabling the offDelay and sleepDelay yet, but will soon.

1 Like

sorry to hear about the failed test with the WiFi. If you have the option of using the USB cable, that might be good to start with. More people have it working with the USB API.

Maybe try and copy the exact configuration for photosphere since Koen has it working for months.

The only thing that isn’t in his README.md is the version of Raspbian he’s using. I think he’s using Raspian Wheezy

Here’s a 24 shot from his project

http://virtualforest.io/vrtimelapse.html

Here’s a 12 hour time lapse with tlapser

At least you know that other people are using the camera in similar applications.

Have you tested different physical cameras and USB cables? I’m wondering if the USB cable or the connector might be a little loose.

In my initial tests with the USB API, I had a problem with the camera not responding to the API after anywhere from a couple of hours to 6 or 8 hours. The disconnect was apparently random. After several days, I isolated an intermittent problem with my USB cable. It worked sometimes, but sometimes did not. I suspect that the cable was borderline usable. Once I changed the cable, I had a stable time lapse system that could take thousands of pictures.

Hopefully, if each person contributes their own experiences, it will eventually help you trace the problem.

Thanks! It’s great to see that others have had success. I have a lot of variables to tease out… camera, usb cable, battery packs, Pi powered / controlled. When I get it working I’ll post all the details, but it will take me a bit since the tests are 8 hours.

1 Like