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

I am trying to build a 24/7 sky monitor using the theta S and a raspberry Pi 3. However, I have had no luck yet. The camera is connected via USB and I use ptpcam to change settings like shutter speed and iso. gphoto2 is used to take pictures, download and erase them directly after each shot.

However, after a few hours the Theta freezes and becomes unresponsive with the power button flashing red. In this case the camera has to be disconnected and rebooted, in order to become responsive again.

Does anyone know, why the camera freezes and becomes unresponsive? has anyone encountered the same problem?

I encountered a problem when my USB cable was a little loose. Try a different cable. Is the air temperature where the THETA is located below freezing? Koen had a problem with the battery freezing.

Most people are using ptpcam to take pictures with the USB. Did you have problems with ptpcam?

When I used gphoto2, I had to remove the gvfs virtual filesystem. There’s a backend process that mounts gvfs, breaking the communication with the camera.

pi@raspberrypi ~ $ sudo apt remove gvfs-backends
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages will be REMOVED:
  gvfs-backends

Suggest you try and use one the solutions below for Raspberry Pi. Once you get it working, then move to your custom solution.

Thanks for the response, I have already tried a different cable. I am currently just testing on my desk, where the temperature is pretty much constantly about 20°C.

As far as I can tell,I did not have any problems with ptpcam.

I have also removed the gvfs stuff.

I only running into problems, after shooting for a few hours. Sometimes after 6 hours, sometimes after 2 days the camera turns unresponsive. I have also tried a different computer.

Have you or someone else tried taking pictures continuously for more than two days straight?

Koen has it running for several months. Suggest you give his code a try. He used ptpcam, not gphoto2.

http://virtualforest.io/about.html

Note that I believe he used an older version of Raspian, not the latest version.

During the several month period, he’s had these issues:

  • camera will not turn on if the power goes off. (tree branch falls on power line)
  • camera battery freezes from time to time. (he has it outdoor near Harvard)

The biggest problem is that the camera can’t turn on by itself if you lose power to the Raspberry Pi.

The longest I’ve personally tested it for is one day.

I suspect, though have not verified, that there may be compatibility issues with the ptpcam libptp on the newer versions of Raspian.

Correct, my issues are cold related not heat related. My setup runs reliable at nominal temperatures (not and extremes I fear - yet to experience heat in summer).

Thanks for all this input and real-world experience. You’ve got the coolest long-term application use of the THETA. Also appreciate that you generously made your project open source.

Well it ain’t rocket science putting this together. Maintaining it is an other story. Might have a cold weather fix in today (keep taking pictures during the night to keep it warm ! ).

2 Likes

The picture below made me think about using the neoprene sleeve of the THETA as a form of thermal insulation. It might help retain the heat from the battery. You’d need to cut the sleeve.

Another solution would be to insert a small, flat, heater like this:

I don’t know anything about this area of hardware hacking, but there’s a bunch of stuff here:

https://www.alibaba.com/product-detail/pet-flat-heating-element-for-heat_60244568517.html

This one in particular looks promising

Maybe this:

https://www.alibaba.com/product-detail/Self-adhesive-flexible-silicone-flat-heating_60497691855.html

The cold might be a common problem for equipment used in agriculture. There might be a off-the-shelf heater to heat something like irrigation control units.

1 Like

The neoprene sleeve idea is wonderful, didn’t think of the sleeve outside the context of protection. In general the resistive heating pads require a lot of power (which I’m short on). So harnessing and retaining heat seems the way to go. Or doing away with the battery all together (but that requires hacking which I will do after the start of the growing season.

1 Like

Found this on IKEA http://m.ikea.com/se/sv/catalog/products/art/40327303/

2 Likes

Had seen it recently as well. Makes a good alternative for my lamp shade.

The first nighttime virtualforest.io image is up. Let’s hope I can fight the cold of this way.

Koen, is it just for keeping the camera warm? I guess the images are black, correct? How often do you think you need to take pictures to keep the heat in the enclosure warm enough?
–Jesse

It’s looks like the same USB API is available with the THETA V.

From RICOH THETA V and RICOH THETA S firmware v01.42, camera control such as shooting over USB connection is available.

2 Likes

THETA V and USB API Usage

Hardware and Software

  • Raspberry Pi 2
  • Raspian Jessie

Not returning capture status, but no problem. It takes several seconds to stitch the picture.

Verify picture was taken. It was.

Download to Raspberry Pi

Change to Video Mode

Start Video Capture

Stop Video Capture

Verify video files were taken

Set To Live Streaming Mode

NOTE: Live streaming can’t be received on a Raspberry Pi due to lack of Linux kernel support of UVC 1.5.

pi@raspberrypi ~/Pictures $ ptpcam --set-property=0x5013 --val=0x8005

Camera: RICOH THETA V
'Still Capture Mode' is set to: [Normal]
Changing property value to 0x8005 [(null)] succeeded.

Set back to still image mode

pi@raspberrypi ~/Pictures $ ptpcam --set-property=0x5013 --val=0x0001

Camera: RICOH THETA V
'Still Capture Mode' is set to: 0x8005 (-32763)
Changing property value to 0x0001 [(null)] succeeded.

Community Usage: Continuous shooting in still image mode

API: InitiateOpenCapture

I heard from a community member that they were able to use InitiateOpenCapture by specifying the first two parameters as 0 and a third parameter, which was set to 1.

Example

ptpcam -R 0x101c,0,0,1. 

Hardware and software:

  • Raspbian Jessie
  • kernel version 4.9.51-v7+
  • libptp2-1.2.0
  • Raspberry Pi 3.
1 Like

Install Instructions for ptpcam

I just did a clean install of ptpcam on a Raspberry Pi Zero. Everything worked great.

Requirements

  • Raspberry Pi (tested on Raspberry Pi 2, Raspberry Pi 3 and Raspberry Pi Zero)
  • Raspbian Jessie
  • THETA V, THETA S, or THETA SC. Device must be powered on
  • USB cable to connect THETA to Rpi
  • libptp2-1.2.0 source files (download)
  • libusb-1.0.21 source files (download)
  • libudev-dev Raspian package
  • basic developer tools such as make, gcc, and associated libraries

Note: Linux on x86 has been reported to work, but we have not documented it as extensively

Instructions

  • install libudev-dev with sudo apt-get install libudev-dev

  • build and install libusb from source

    ./configure
    make
    sudo make install

  • build and install libptp from source

  • ptpcam will be in /usr/local/bin. Add this to your PATH

    export PATH=$PATH:/usr/local/bin

  • libptp2 will be in /usr/local/lib. Add this to your LD_LIBRARY_PATH

    export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib

  • add the two lines for PATH and LD_LIBRARY_PATH to your .bashrc file or /etc/environment

  • Use ptpcam as root

     $ sudo bash
     # ptpcam -i
1 Like

Full Install Guide From Raspbian to libptp - Step by Step

Download Raspbian jessie

Available from the official raspberrypi.org image archive.

I’m using raspian-2017-07-05

Burn image to microSD card

Download Etcher. Follow onscreen directions

Connect Raspberry Pi to Workstation

In my case, I’m using a CP210x USB to UART Bridge. This is a $5 device that allows the Raspberry Pi to be powered directly from the GPIO pins and allows connection to my Windows 10 workstation via USB.

The picture below shows the full setup I use to program the Pi. To deploy the Pi, disconnect the wires connected to the GPIO pins and attach a power source to the Pi, either USB or header (the GPIO group) pins.

Most people will probably connect to the Raspberry Pi with Ethernet or WiFi and ssh.

If you use a USB cable to connect to the Raspberry Pi, here are the pins on the Pi.
image

Match the RX and TX pins on the Pi to the RX and TX pins to your USB to TTL bridge.
image

If you want to power the Pi from the USB to TTL connector, then also plug in the 5V and GND.

You may need to mount the microSD card of the Raspberry Pi on your workstation and edit the file /boot/config.txt and add enable_uart= to the bottom of the file.

I can now log into the Raspberry Pi from Windows without knowing the IP address or having configure Windows to serve up an IP address.

Download libptp2 from Sourceforge

I have Ethernet connected and my Raspberry Pi is connected to the Internet.

I’m using the text browser links to download libptp2

  pi@raspberrypi:~$ sudo apt-get install links

  pi@raspberrypi:~$ links https://sourceforge.net/projects/libptp/files/libptp2/

Download libusb from Sourceforge

Verify and Extract Files

pi@raspberrypi:~/Development$ ls -l
total 992
-rw-r--r-- 1 pi pi 404105 Oct  4 04:11 libptp2-1.2.0.tar.gz
-rw-r--r-- 1 pi pi 607417 Oct  4 04:14 libusb-1.0.21.tar.bz2
pi@raspberrypi:~/Development$

pi@raspberrypi:~/Development$ tar xvf libusb-1.0.21.tar.bz2
libusb-1.0.21/
libusb-1.0.21/aclocal.m4

pi@raspberrypi:~/Development$ cd libusb-1.0.21/
pi@raspberrypi:~/Development/libusb-1.0.21$ ls
aclocal.m4  config.guess  COPYING   install-sh        Makefile.am  PORTING
android     config.h.in   depcomp   libusb            Makefile.in  README
AUTHORS     config.sub    doc       libusb-1.0.pc.in  missing      tests
ChangeLog   configure     examples  ltmain.sh         msvc         TODO
compile     configure.ac  INSTALL   m4                NEWS         Xcode
pi@raspberrypi:~/Development/libusb-1.0.21$

install libudev-dev

Running ./configure for libusb generated this error.

checking libudev.h usability... no
checking libudev.h presence... no
checking for libudev.h... no
configure: error: "udev support requested but libudev not installed"
pi@raspberrypi:~/Development/libusb-1.0.21$

Install libudev-dev

$ sudo apt-get install libudev-dev
Reading package lists... Done
Building dependency tree

Run configure again.

Then run make.

$ make
make  all-recursive
make[1]: Entering directory '/home/pi/Development/libusb-1.0.21'
Making all in libusb
make[2]: Entering directory '/home/pi/Development/libusb-1.0.21/libusb'
  CC       libusb_1_0_la-core.lo
  CC       libusb_1_0_la-descriptor.lo
....
make[2]: Leaving directory '/home/pi/Development/libusb-1.0.21/libusb'
Making all in doc
make[2]: Entering directory '/home/pi/Development/libusb-1.0.21/doc'
make[2]: Nothing to be done for 'all'.
make[2]: Leaving directory '/home/pi/Development/libusb-1.0.21/doc'
make[2]: Entering directory '/home/pi/Development/libusb-1.0.21'
make[2]: Leaving directory '/home/pi/Development/libusb-1.0.21'
make[1]: Leaving directory '/home/pi/Development/libusb-1.0.21'
pi@raspberrypi:~/Development/libusb-1.0.21$

make install

Libraries have been installed in:
   /usr/local/lib

If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the `-LLIBDIR'
flag during linking and do at least one of the following:
   - add LIBDIR to the `LD_LIBRARY_PATH' environment variable
     during execution
   - add LIBDIR to the `LD_RUN_PATH' environment variable
     during linking
   - use the `-Wl,-rpath -Wl,LIBDIR' linker flag
   - have your system administrator add LIBDIR to `/etc/ld.so.conf'

Check to make sure libusb is in /usr/local/lib

$ ls /usr/local/lib
libusb-1.0.a   libusb-1.0.so    libusb-1.0.so.0.1.0  pypy2.7    python3.4
libusb-1.0.la  libusb-1.0.so.0  pkgconfig            python2.7

Add /usr/local/lib to linker path

$ export LDFLAGS='-L/usr/local/lib/'

install libptp

Follow the same process of extract, configure, make, and sudo make install.

Extract

$ tar xvf libptp2-1.2.0.tar.gz
libptp2-1.2.0/
libptp2-1.2.0/m4/

make

 ....
cal/lib/ /home/pi/Development/libptp2-1.2.0/src/.libs/libptp2.so -L/usr/local/lib /usr/local/lib/libusb.so
make[2]: Leaving directory '/home/pi/Development/libptp2-1.2.0/src'
make[2]: Entering directory '/home/pi/Development/libptp2-1.2.0'
make[2]: Leaving directory '/home/pi/Development/libptp2-1.2.0'
make[1]: Leaving directory '/home/pi/Development/libptp2-1.2.0'

Test

root@raspberrypi:/home/pi/Development# export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib
root@raspberrypi:/home/pi/Development# ptpcam -i

Camera information
==================
Model: RICOH THETA V
  manufacturer: Ricoh Company, Ltd.
  serial number: '00101082'
  device version: 1.00.2
  extension ID: 0x00000006
  extension description: (null)
  extension version: 0x006e


root@raspberrypi:/home/pi/Development# ptpcam -c

Initiating captue...
Object added 0x400d0004
Events receiving error. Capture status unknown.
root@raspberrypi:/home/pi/Development# ptpcam -L

Listing files...
Camera: RICOH THETA V
Handler:           Size:        Captured:       name:
0x0000002d:      1970120        2017-09-28 12:58        R0010025.JPG
0x0000002e:      2402374        2017-09-28 12:58        R0010026.JPG
0x0000002f:      2136165        2017-09-28 12:58        R0010027.JPG
0x00000030:      2810985        2017-09-28 12:59        R0010028.JPG
0x00000031:     97458043        2017-09-28 21:08        R0010029.MP4
0x00000032:      1064880        2017-10-02 15:31        R0010030.JPG
0x00000033:    722622498        2017-10-02 15:53        R0010031.MP4
0x00000034:    131377941        2017-10-02 15:57        R0010032.MP4
0x00000035:      1040761        2017-10-02 16:02        R0010033.JPG
0x00000039:      1295975        2017-10-03 22:00        R0010034.JPG

root@raspberrypi:/home/pi/Development#

Check battery level

# ptpcam --show-property=0x5001

Camera: RICOH THETA V
'Battery Level' is set to: 70
root@raspberrypi:/home/pi/Development#

Set to video mode

# ptpcam --set-property=0x5013 --val=0x8002

Camera: RICOH THETA V
'Still Capture Mode' is set to: [Normal]
Changing property value to 0x8002 [(null)] succeeded.
root@raspberrypi:/home/pi/Development#

Note on old libusb

Depending on the configuration, ai needed to install an old libusb-0.1.12 to build libptp2.

# ls -l
total 1388
drwxr-xr-x  4 pi pi   4096 Oct  4 04:54 libptp2-1.2.0
-rw-r--r--  1 pi pi 404105 Oct  4 04:11 libptp2-1.2.0.tar.gz
drwxr-xr-x  7 pi pi   4096 Oct  4 04:52 libusb-0.1.12
-rw-r--r--  1 pi pi 389343 Oct  4 04:50 libusb-0.1.12.tar.gz
drwxr-xr-x 10 pi pi   4096 Oct  4 04:20 libusb-1.0.21
-rw-r--r--  1 pi pi 607417 Oct  4 04:14 libusb-1.0.21.tar.bz2
root@raspberrypi:/home/pi/Development#

Troubleshooting

Problem: libptp2.so.1: cannot open shared object file

pi@raspberrypi:~$ ptpcam -L
ptpcam: error while loading shared libraries: libptp2.so.1: cannot open shared object file: No such file or directory

Solution:

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib


Problem: ERROR: Could not open session!

pi@raspberrypi:~$ ptpcam -L

Listing files...
ERROR: Could not open session!

Solution:

change to root with sudo or sudo bash.


Problem: not working after reboot

Solution

add export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib to your .bashrc file, both to your default user and to your home directory when you are logged in as root.


Problem: libptp build is failing

Solution

Try installing an older version of libusb such as libusb-0.1.12 to build libptp2.

Question Regarding Windows IoT Core

Has anyone attempted to use Windows IoT Core with the RICOH THETA V? One of the reasons I’m asking is because of the lack of full support for UVC 1.5 in the Linux kernel. This is preventing the Raspberry Pi with Raspbian from being used as a platform for live streaming with the THETA V.

I’m wondering if a Raspberry Pi with Windows IoT Core can display the THETA V video stream. Has anyone tried this?

I was planning to take a look at this:

https://developer.microsoft.com/en-us/windows/iot/samples/webcamapp

and this

The device needs to support UVC 1.5. The Linux kernel supports UVC 1.1 and can detect UVC 1.5, but can’t handle the video compression with UVC 1.5, thus making it unusable by mere mortals with the THETA V.

has anyone tried this?

Though, this thread doesn’t sound promising. From Aug 24, 2017, seems like lack of hardware graphics acceleration…

Oh, please, if MS is working on an updated Windows BSP for Raspberry Pi, please, please, add hardware graphics acceleration, audio through HDMI (and possibly OpenGL) so that RPi can become a useful platform in making it stream and play A/V, and do things like video face recognition for app security without having to resort to using Raspian.

Thursday, August 24, 2017 6:02 AM

In case anyone is trying to get the live stream on a Raspberry Pi, there’s been some success on Android and it’s theoretically possible to get it to work on the Rasbperry Pi. If you have an example, please post it.

Hey, so im trying to get a live stream over USB to an Android device on the THETA V. The app mentioned in this post in no longer on the play store THETA V 4K Live Mobile Streaming - Free App. Do you know what the current status is for USB streaming to Android? Thanks