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

You can use your mobile phone as a hotspot and stream to a RTMP server like Facebook or YouTube with the plug-in below:

http://theta360.guide/plugin-user-guide/wireless-stream/

You can get the 4K stream onto something like Oculus Go with webRTC.

I do not know of any public application that allows a USB cable to stream to an Android device.

I know people have successfully done this for their own work projects (source code not released).

2 Likes

Super great work you are all doing here! I have a project that I am doing right now in Panama where I am trying to make 360 Camera trap prototypes. We got the first up and going with the MADV camera because it was easy to control with two pins they had broken out that you can just short to turn the camera on and take photos, etc

https://www.instagram.com/p/B2DgYfBlqic/?utm_source=ig_web_copy_link

But now i am trying to make one with the Theta V, but running into much more difficulties.

The basics we need are to:

  1. Turn on the camera (and at least be able to turn it off) given a response from an autonomous Arduino
  2. Trigger it to take a photo or record a video
  3. turn itself back off (at least to sleep mode)

I asked Theta support and they told me it couldn’t be done.
But after some hacking, i have some promising findings.

A) If i connect an arduino via an OTG cable set up as a Human Interface Device (HID), and send it a key stroke, it will wake up from sleep

B) If i run the HID plugin on the Theta V, i can completely control the shooting with an Arduino emulating a keyboard (It’s great!). BUT the camera will not automatically start up in Plugin Mode

C) if i connect the CA-3 remote shutter, it can make the camera take photos without any plugin over the USB, BUT the CA-3 cannot wake the camera up.

So I am able to do all the actions i need, but not all with the same device.

Does anyone know
A) how to send the USB Api triggers from an Arduino? (Teensy has USB serial support)
B) How to start up the camera in plugin mode?
or
C) What the CA-3 is sending to trigger the photo?

1 Like

Another question will be:
is it possible to supply power TO the Theta over the USB while also sending messages?

I know that it is possible to draw power from the Theta to run my Teensy attached to just the USB for example, but i don’t know if i can send power the other way?

You can power the THETA over USB and send USB API commands to it. It will work indefinitely. I need to review the rest of your questions in more detail. Breakfast is on the table. Have to run.

Modification to ptp.h needed

ptpcam and programs using libptp2-1.2 may not work properly without a small modification to the line 77. Change the PTP_USB_INT_PACKET_LEN to 28

to install in /usr/local/lib and usr/local/bin run

$ make clean
$ make
$ sudo make install

In your ~/.profile, add this line:

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

run

source ~/.profile

Alternately, you can add the library path to a file in /etc/ld.so.conf.d and run

$ sudo ldconfig

craig@jetson:/etc/ld.so.conf.d$ cat libc.conf 
# libc default configuration
/usr/local/lib
craig@jetson:/etc/ld.so.conf.d$ 

WpdMtp for RICOH THETA

Library for operating MTP devices from C# and operating cameras such as the RICOH THETA.

Usage

  • create an instance of MtpCommand
  • Get a list of RICOH THETA device IDs connected to the PC with GetDeviceIds() of MtpCommand.
  • Use the Open() method of MtpCommand to connect to the RICOH THETA
  • Execute() will send and run an MTP command on the RICOH THETA
  • Close() will disconnect from the THETA

Warning

  • Unexpected errors may occur in various places. Use it systematically and carefully.
  • OpenSession and CloseSession seem to be done automatically by Windows (unconfirmed)

Reference

With ptpcam -R, it can send a raw generic PTP request with parameters. The returned result could be reformated to shutter speed settings of Theta S. First read properties available, 0x1014 for reading device property description and 0xd00f for shutter speed. In the returned values, all the possible shutter speed is listed. For example, 01 00 00 00 a0 0f 00 are two 4-bype integers, 01 00 00 00 is 1 and a0 0f 00 00 is actually 0f a0 which is 6400.

$ ptpcam -R 0x1014,0xd00f,0,0,0,r
Camera: RICOH THETA S
Sending generic request: reqCode=0x1014, params=[0x0000d00f,0x00000000,0x00000000,0x00000000,0x00000000]
0f d0 08 00 01 00 00 00 00 00 00 00 00 01 00 00 - ................
00 3c 00 00 00 02 37 00 01 00 00 00 00 19 00 00 - .<....7.........
01 00 00 00 88 13 00 00 01 00 00 00 a0 0f 00 00 - ................
01 00 00 00 80 0c 00 00 01 00 00 00 c4 09 00 00 - ................
01 00 00 00 d0 07 00 00 01 00 00 00 40 06 00 00 - ............@...
...........

To get current setting of a property, 0x1015 for get property and 0xd00f for shutter speed:

$ptpcam -R 0x1015,0xd00f,0,0,0,r

Camera: RICOH THETA S
Sending generic request: reqCode=0x1015, params=[0x0000d00f,0x00000000,0x00000000,0x00000000,0x00000000]
01 00 00 00 3c 00 00 00 00 00 00 00 - ....<.......
PTP: response OK

The result 01 00 00 00 3c 00 00 00 could be read as (01)/(3c) = 1/60
To set shutter speed, could send binary data with ptpcam -R. To send 1/8, use 0x1016 for set property:

echo -e -n '\x01\x00\x00\x00\x08\x00\x00\x00' > shutter.bin
ptpcam -R 0x1016,0x00f,0,0,0,0,shuuter.bin

There’s a new Linux streaming driver that allows streaming over a USB cable to a Linux computer. I’ve seen it working a NVIDIA Jetson with the livestream controlled by the USB API.

https://theta360.guide/special/linuxstreaming/

https://api.ricoh/docs/theta-usb-api/property/still_capture_mode/

Update Aug 28, 2020

I just sent out full libptp build and usage information for Jetson Nano with JetPack 4.4 (Ubuntu 18.04) to the Linux 360 Live Streaming Online Meetup Registrants.

https://theta360developers.github.io/linux-streaming-meetup/

1 Like

I tried to run “ptpcam -R 0x101c” but I got an error and could not start video recording with Theta V.

Camera: RICOH THETA V
Sending generic request: reqCode=0x101c, params=[0x00000000,0x00000000,0x00000000,0x00000000,0x00000000]
PTP: Invalid Parameter
PTP: ERROR: response 0x201d

According to the past thread, it seems to work on Ubuntu 14.xx, but I want to use ROS Kinetic, so I can’t change the version down.

I hope you can somehow make it possible to record video.
Also, there are a number of other commands that can’t be executed for something else.
Is this an error for the same reason?

I’ve written a version of the elements that might be necessary for a smooth resolution.
I’ll keep adding to it as requested.

The version of each element

OS Ubuntu 16.04 LTS
kernel 4.4.0-187-GE
machine Inspiron 7520
packages
. build-essential 12.1ubuntu2
. libtool 2.4.6-0.1
. automake 1:1.15-4ubuntu1
. pkg-config 0.29.1-0ubuntu1
. subversion 1.9.3-2ubuntu1.3
. libusb-dev 2:0.1.12-28
. libptp2 1.2.0
Theta V’s FW 3.40.1

I’m Japanese, so it would be helpful if you could write in simple English, which is easy to translate.
This sentence has been translated at DeepL

start capture to save video to file

ptpcam -R 0x101c,0,0,1
1 Like

wow!
Thank you so much, craig!
What an easy, simple, startling, brilliant answer! I can’t believe that adding just “,0,0,1” to the bottom works perfectly!
My less than 4 hours(?) So much trouble and time spent searching can be solved with just one post!
That’s the power of community! That’s fantastic!
I knew from the specs to add “,0,0”.
But where is the information on the last “,1”?
I thought I did my best to look into it, as mentioned above, but I couldn’t find a way to do so.
Maybe I just missed it.
But still, thank you so much.

1 Like

Hi all, glad to find this community! I’m new to theta development. We are now working on a project to setup a Theta Z1 camera in a remote site. The Z1 camera is connected to a computer through USB and we use it to stream live 360° video. As it’s a remote site without regular workers, we want to control the camera remotely. Sometimes we may put the camera and computer into sleep mode. However, we can’t find a way to turn on the Z1 camera from the sleep mode. We have to turn on the camera by manually pressing the power button. I would like to know if there’s a way to turn on the camera from the computer with USB connected. Thanks a lot!

wake from sleep

$ ptpcam --set-property=0xD80E --val=0x00

Camera: RICOH THETA Z1
'UNKNOWN' is set to: 1
Changing property value to 0x00 [(null)] succeeded.

@NaokiSato102, thank you for the nice note. With the surge of interest in the live streaming to Linux topic, there is now more activity on the USB API. I am working on a new document with a table of contents. If you have additional questions, feel free to ask.

My current test setup:

  • NVIDIA Jetson running JetPack 4.4 (Ubuntu 18.04). USB API and live streaming work
  • x86 64 running Ubuntu 20.04. USB API and live streaming work

If this information is useful, you can help us out by telling us more about your project. 日本語 is OK.
We report back to RICOH on what the community is doing. This helps us maintain sponsorship for testing and creation of documentation we can make available to the community. You can send the information to @jcasman by DM or email. Thank you.

I added the information to the new document which is available to the people that registered for the meetup right now. We’ll make it available to everyone else in about a week.

Thanks Craig! We will give it a try!

I understand, @craig.
I can just let @jcasman know what I’m doing by DMing or some other way, right?
But what kind of content should I send? I don’t know if I can send just the content to @jcasman because it might confuse him.

Would the following be sufficient?
Greetings
Brief self-introductions
@craig asked me to introduce what I’m doing.
Contents(what I’m doing)
I’m waiting for your reply.

By the way, will the URL be posted here when the document is completed or published?

Translated from Japanese by DeepL
Is it @craig or @jcasman who says it’s okay to speak Japanese?

This is what it looked like when I tried it in my environment. Is it the same for all of you?
What I can see from this table is that, for now, it’s safe to use “ptpcam -R 0x101c,0,0,1”.
私の環境で試したところこんな感じになりました。みなさんも一緒ですか?
この表からわかることは、とりあえず、「ptpcam -R 0x101c,0,0,1」を使っておけば安泰ということですね。

. ptpcam -R 0x101c ptpcam -R 0x101c,0,0,1
(My)Theta V :heavy_multiplication_x: :heavy_check_mark:
(My)Theta S :heavy_check_mark: :heavy_check_mark:

yes, I believe it’s the same. I believe the V and Z1 are the same.

I must have first encountered this in Sept of 2017 with the V. See this post. There must have been a problem with the V without the additional 0,0,1

1 Like

Thank you for your help. Please fill out the short survey below. Japanese is OK. Both @jcasman and I can read Japanese.

Is there anyone can give me a complete guide of how to do API over USB Cable for Z1, as I am not a developer so it is kinda hard for me to understand the process. I want to try to do a factory reset to my Z1 using API, maybe it would fix the problems, as my Z1 won’t boot and keep getting error during the boot process.