Page tree
Skip to end of metadata
Go to start of metadata

We are using Ricoh's Theta SC 360º camera for continuous time-lapse images. The Theta SC is not the most recent 360º from Ricoh, nor is it necessarily the best on the market, but it has several advantages for a project like OpenVino:

  • Low-cost
  • Published API
  • similar projects to reference
  • 24x7 operability (temperature tolerant)
  • It is the camera we have...

Many interesting projects with Theta cameras are out in the wild, and documented. Much of the documentation on this page, and others, is lifted directly from these sources:

https://community.theta360.guide/t/ricoh-theta-api-over-usb-cable-z1-v-s-sc-models/65

http://virtualforest.io

The RICOH THETA SC provides open API access so you can connect to the camera and build applications and devices that take advantage of camera’s low-cost, versatile 360 degree image and video capabilities. 

There are two ways to access the camera API: Over wifi and over USB.

Wifi
The RICOH THETA SC 360 camera can be controlled with an API that is accessible using WiFi. Version 2 of the API is compliant with Google Open Spherical Camera API specification.

USB
An alternative to using the RICOH THETA S API over WiFi exists that works over a USB cable. This is a different API and requires firmware version 01.42 or later. v2 USB API uses extended PTP, or Picture Transfer Protocol, as the communications protocol.

There are pros and cons for using each method, depending on your specific requirements. Some of the differences are quickly highlighted here:


Getting Started with the RICOH THETA USB API


Official RICOH THETA USB Reference v2 389

On the RICOH developer forum, MattWymore posted this 49:

Building Time-lapse

The object is to collect still images for reporting what is happening on the vineyard, and create beautiful time-lapse images to share with the world. Thus we are essentially publishing 

  • Last image
  • Day time-lapse
  • Month time-lapse
  • Year time-lapse

And we are archiving all the images on IPFS.

Image volume

Each image taken by the Theta SC has a resolution of 5376×2688 pixels, which is equivalent to approximately 14 megapixels. 

The file size for each image is approximately 4MB.



DayMonthYear

Image Size (MB)457601728002102400


4130058photo frequency (mins)Total imagesFile sizeVideo frames per secondVideo duration (seconds)
24h time-lapse
1144057602460
Month time-lapse
6072028802430
Year time-lapse
144036514602415

Collecting time-lapse images from the Theta SC, via USB from a Raspberry Pi (openvinopi):

  1. Determine when and how to take a photograph
    1. when (cron entry or continuos loop)
    2. how (light settings)
  2. Trigger the photograph from openvinopi
    1. Take the picture
    2. Download the picture from Theta SC to openvinopi
    3. Erase the picture on the camera
  3. Process the image
    1. include metadata (hash for blockchain)
    2. publish the still image (as most recent image on web)
  4. Create a timelapse of the past 24h
    1. Select the appropriate images
    2. Concatenate the images into a 360º video
    3. Publish the video to YouTube with appropriate metadata
    4. Archive images
  5. Create a timelapse of the past month?
    1. Select the appropriate images
    2. Concatenate the images into a 360º video
    3. Publish the video to YouTube with appropriate metadata
  6. Create a timelapse of the season - May6 - May6
    1. Select the appropriate images
    2. Concatenate the images into a 360º video
    3. Publish the video to YouTube with appropriate metadata

Software components

USB connection

First check to see that the camera is visible from raspbian:

pi@vinoblock:~ $ lsusb
Bus 001 Device 004: ID 05ca:0367 Ricoh Co., Ltd 
Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp. SMSC9512/9514 Fast Ethernet Adapter
Bus 001 Device 002: ID 0424:9514 Standard Microsystems Corp. SMC9514 Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

gphoto2

gphoto2 is the software used to capture images from the camera, via USB. 

gphoto2 uses ptpcam.


Install gphoto2

pi@vinoblock:~ $ sudo apt-get install gphoto2.

Check the status of the camera from gphoto2.


pi@vinoblock:~ $ sudo gphoto2 --summary   

Camera summary:                                                                
Manufacturer: Ricoh Company, Ltd.
Model: RICOH THETA SC
  Version: 01.20
  Serial Number: 30101959
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: 7939817472 (7572 MB)
 Free Space (Bytes): 5985708032 (5708 MB)
 Free Space (Images): 1201

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) '20200427T204232-0300'
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,32775] 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,32771,32772] 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: 33
Property 0xd006:(read only) (type=0x6) 0
Property 0xd00f:(readwrite) (type=0x8) Enumeration [15] value: -36348160
Property 0xd801:(readwrite) (type=0xffff) ''
Property 0xd802:(readwrite) (type=0x2) Range [0 - 30, step 1] value: 0
Property 0xd803:(readwrite) (type=0x4) Range [0 - 1800, step 1] value: 300
Property 0xd805:(readwrite) (type=0xffff) 'THETAYJ30101959.OSC'
Property 0xd806:(readwrite) (type=0xffff) '30101959'
Property 0xd807:(readwrite) (type=0x2) Enumeration [0,1,6,11] value: 0
Property 0xd808:(read only) (type=0x2) Enumeration [0,1,2,3] value: 0
Property 0xd809:(read only) (type=0x4) Range [0 - 299, step 1] value: 0
Property 0xd80a:(read only) (type=0x4) Range [0 - 300, 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: 1
Property 0xd80d:(read only) (type=0x4) 2983
Property 0xd80e:(readwrite) (type=0x2) Enumeration [0,1] value: 0
Property 0xd80f:(readwrite) (type=0x6) Range [600 - 86400, step 600] value: 86400
Property 0xd810:(readwrite) (type=0x6) Range [0 - 600, step 60] value: 0
Property 0xd811:(read only) (type=0x6) Range [0 - 86400, step 1] value: 0
Property 0xd812:(readwrite) (type=0x0) Undefined
Property 0xd813:(readwrite) (type=0x4) Range [2500 - 10000, step 100] value: 5000


Take a picture, download the picture and delete the picture from the camera:



pi@vinoblock:~ $ sudo gphoto2 --capture-image-and-download
New file is in location /store_00010001/DCIM/100RICOH/R0013444.JPG on the camera
Saving file as R0013444.JPG                                                    
Deleting file /store_00010001/DCIM/100RICOH/R0013444.JPG on the camera

ptpcam

We need to install ptpcam as well, for managing camera functions, such as shutterspeed and monitoring battery levels (in case of voltage problems).


To compile libptp2 on Raspberry PI one has to install following dependencies:

apt-get -y install build-essential &&
apt-get -y install libtool &&
apt-get -y install automake &&
apt-get -y install pkg-config &&
apt-get -y install subversion &&
apt-get -y install libusb-dev

Then checkout the current source code:

svn checkout svn://svn.code.sf.net/p/libptp/code/trunk libptp-code

Compile the libptp2 and its companion tool:

cd libptp-code

./autogen.sh
./configure
make


And finally install:

sudo make install 
sudo ldconfig


Make sure that you properly connected the camera and the user you run ptpcam has proper permissions to access USB devices. If you stumble upon something like:

# ptpcam -l

Listing devices...
bus/dev vendorID/prodID device model
ERROR: Could not open session!
Try to reset the camera.

# dmesg | tail
[829332.584482] usb 1-1.5.1: new full-speed USB device number 46 using dwc_otg
[829332.689240] usb 1-1.5.1: New USB device found, idVendor=04b0, idProduct=040e
[829332.689259] usb 1-1.5.1: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[829332.689271] usb 1-1.5.1: Product: NIKON DSC D70s
[829332.689282] usb 1-1.5.1: Manufacturer: NIKON
[829336.094289] usb 1-1.5.1: usbfs: interface 0 claimed by usbfs while 'ptpcam' sets config #1
[829336.094598] usb 1-1.5.1: usbfs: process 8416 (ptpcam) did not claim interface 0 before use

Manipulating properties

To list the properties that your camera support use the -p switch:

# ptpcam -p 

Listing properties...
Camera: D3300
 0x5001: Battery Level
 0x5003: Image Size
 0x5004: Compression Setting
 0x5005: White Balance
 0x5007: F-Number
 0x5008: Focal Length
 0x500a: Focus Mode
 0x500b: Exposure Metering Mode
 0x500c: Flash Mode
 0x500d: Exposure Time
 0x500e: Exposure Program Mode
 0x500f: Exposure Index (film speed ISO)
 0x5010: Exposure Bias Compensation
 0x5011: Date Time
 0x5013: Still Capture Mode
 0x5018: Burst Number
 0x501c: Focus Metering Mode
 0xd303: UNKNOWN
 0xd406: UNKNOWN
 0xd407: UNKNOWN

Unfortunately not all proprietary extension properties are documented or reversed and hence listed as UNKNOWN (though you might still be able to identify and manipulate them).

Properties can be of various types like UINT8, UINT32, INT16, STRING, etc. and its values can be either random (rarely), range (for numeric properties) or enumerated (any  type). To show property along its value and description use switch -s together with -v:

# ptpcam -s 0x5001 -v

Camera: D3300
Battery Level: [0x5001, readonly, UINT8] 
 Current value: 100
 Factory value: 100
Range [0 - 100; step 1]


Alternatively you can also use the textual property names with abbreviations, like this (–set without –val is equivalent of -s):

# ptpcam --set Battery -v

Camera: D3300
Battery Level: [0x5001, readonly, UINT8] 
 Current value: 100
 Factory value: 100
Range [0 - 100; step 1]

From the output we can find that property Battery Level is a readonly property (of UINT8 type), its current value is 100 and possible values are in range between 0and 100 with step of 1.

Other properties are settable, for example:

# ptpcam -s 0x5003 -v

Camera: D3300
Image Size: [0x5003, readwrite, String] 
 Current value: "4496x3000"
 Factory value: "6000x4000"
Enumerated:
"6000x4000"
"4496x3000"
"2992x2000"

The Image Size property is a string and is readwrite. Please note that some properties (in example F-Stop) can be set only in certain camera modes (Manual, Aperture Priority)  so make sure you turn the dial to proper mode before complain that given property is readonly.

To obtain the overview of camera properties use –show-all-properties switch along -v:

# ptpcam --show-all-properties -v

Camera: D200
 0x5001: (Battery Level) 50
 0x5003: (Image Size) "3872x2592"
 0x5004: (Compression Setting: JPEG Normal) 1
 0x5005: (White Balance: Automatic) 2
 0x5007: (F-Number: 16.0) 1600
 0x5008: (Focal Length: 18mm) 1800
 0x500a: (Focus Mode: Manual) 1
 0x500b: (Exposure Metering Mode: Multi-spot) 3
 0x500c: (Flash Mode: Front-courtain) -32752
 0x500d: (Exposure Time: 0.1000s) 1000
 0x500e: (Exposure Program Mode: Manual) 1
 0x500f: (Exposure Index (film speed ISO)) 400
 0x5010: (Exposure Bias Compensation: 0.0) 0
 0x5011: (Date Time) "20150610T220559"
 0x5013: (Still Capture Mode: Single Frame) 1
 0x5018: (Burst Number) 1
 0x501c: (Focus Metering Mode: Single Area) -32752


Some cameras support less properties while others support more:

# ptpcam --show-all-properties -v

Camera: D70s
 0x5001: (Battery Level) 100
 0x5003: (Image Size) "3008x2000"
 0x5004: (Compression Setting: JPEG Fine) 2
 0x5005: (White Balance: Automatic) 2
 0x5007: (F-Number: 0.0) 0
 0x5008: (Focal Length: 0mm) 0
 0x500a: (Focus Mode: Manual) 1
 0x500b: (Exposure Metering Mode: Multi-spot) 3
 0x500c: (Flash Mode: Front-courtain) -32752
 0x500d: (Exposure Time: 0.1666s) 1666
 0x500e: (Exposure Program Mode: Manual) 1
 0x500f: (Exposure Index (film speed ISO)) 200
 0x5010: (Exposure Bias Compensation: 0.0) 0
 0x5011: (Date Time) "20150611T001523"
 0x5013: (Still Capture Mode: Single Frame) 1
 0x5018: (Burst Number) 1
 0x501c: (Focus Metering Mode: Single Area) -32752
 0xd017: (NIKON White Balance Auto Bias) 0
 0xd018: (NIKON White Balance Tungsten Bias) 0
 0xd019: (NIKON White Balance Flourescent Bias) 1
 0xd01a: (NIKON White Balance Daylight Bias) 3
 0xd01b: (NIKON White Balance Flash Bias) 2
 0xd01c: (NIKON White Balance Cloudy Bias) 0
 0xd01d: (NIKON White Balance Shade Bias) 1
 0xd01f: (UNKNOWN) 0
 0xd025: (UNKNOWN) 28115589
 0xd026: (UNKNOWN) 36372868
 0xd02a: (NIKON Image Sharpening: -2 Low) 2
 0xd02b: (NIKON Tone Compensation: Normal) 1
 0xd02c: (NIKON Color Mode: IIIa (sRGB)) 2
 0xd02d: (NIKON Hue Adjustment) 0
 0xd045: (UNKNOWN) 0
 0xd04f: (NIKON Focus Area Wrap: No Wrap) 0
 0xd054: (NIKON ISO Auto: Off) 0
 0xd056: (NIKON EV Step: 1/3) 0
 0xd058: (NIKON Exposure Compensation by Command Dial only: Off) 0
 0xd059: (NIKON Center Weighted Area: 8mm) 1
 0xd05e: (NIKON AE Lock Mode: AE-L Button) 0
 0xd05f: (NIKON AE-L/AF-L Mode: Exposure and Focus Lock) 0
 0xd062: (NIKON Meter-Off: 6s) 1
 0xd063: (NIKON Self Timer: 10s) 2
 0xd064: (NIKON Monitor Off: 20s) 1
 0xd06b: (NIKON Long Exposure Noise Reduction: On) 1
 0xd06c: (NIKON File Number Sequence: On) 1
 0xd075: (NIKON Slowest Flash Shutter Speed: 1/60) 0
 0xd078: (NIKON Bracket Set: AE & Flash) 0
 0xd07a: (NIKON Bracket Order: MTR->Under->Over) 0
 0xd086: (NIKON Reverse Command Dials: Yes) 1
 0xd08a: (NIKON No CF Card: Enabled Release) 0
 0xd090: (NIKON Image Comment String) " "
 0xd091: (NIKON Image Comment Attach: Off) 0
 0xd092: (NIKON Image Rotation: Automatic) 0
 0xd0c0: (NIKON Bracketing: Off) 0
 0xd0c2: (NIKON Bracketing Program: +2F) 1
 0xd0c3: (UNKNOWN) 1
 0xd0c4: (NIKON White Balance Bracket Step) 0
 0xd0c5: (UNKNOWN) 0
 0xd0e0: (NIKON Lens ID) 0
 0xd0e1: (UNKNOWN) 0
 0xd0e2: (UNKNOWN) 0
 0xd0e3: (NIKON Min. Focal Length: 0) 0
 0xd0e4: (NIKON Max. Focal Length: 0) 0
 0xd0e5: (NIKON Max. Aperture at Min. Focal Length: 0.0) 0
 0xd0e6: (NIKON Max. Aperture at Max. Focal Length: 0.0) 0
 0xd100: (NIKON Exposure Time: 1/6) 65542
 0xd101: (NIKON AC Power) 0
 0xd102: (UNKNOWN) 0
 0xd103: (NIKON Maximum Shots) 2
 0xd104: (NIKON AF-L Locked) 0
 0xd105: (NIKON AE Lock: Not Locked) 0
 0xd106: (NIKON AF Lock) 0
 0xd108: (NIKON Autofocus Area selector: <CENTER>) 0
 0xd109: (UNKNOWN) 0
 0xd10a: (NIKON Light Meter) 0
 0xd10d: (UNKNOWN) "NO= 1006b1f2 "
 0xd10e: (NIKON Camera orientation: Landscape) 0
 0xd10b: (UNKNOWN) 0
 0xd120: (UNKNOWN) 0
 0xd121: (UNKNOWN) 0
 0xd122: (UNKNOWN) 0
 0xd124: (UNKNOWN) 0
 0xd125: (UNKNOWN) 1
 0xd126: (NIKON Flash Exposure Compensation: 0.0) 0
 0xd140: (NIKON Optimize Image: Vivid) 1
 0xd142: (NIKON Saturation: Moderate) 1
 0xd160: (NIKON Beep: On) 0
 0xd161: (NIKON Autofocus Mode: AF-S (single-servo)) 0
 0xd163: (NIKON AF Assist Lamp: On) 0
 0xd164: (NIKON Auto ISO shutter limit for P A and DVP Mode: 1/30) 2
 0xd165: (NIKON Image Review: On) 0
 0xd166: (NIKON AF Area Illumination: Auto) 0
 0xd167: (NIKON Flash Mode: TTL) 0
 0xd168: (NIKON Flash Commander Mode: TTL) 0
 0xd169: (NIKON Flash Signal Indicator: On) 0
 0xd16b: (NIKON Remote Timeout: 1min) 0
 0xd16c: (NIKON Viewfinder Grid Display: Off) 0
 0xd16d: (NIKON Flash Manual Mode Power: Full power) 0
 0xd16e: (NIKON Flash Commander Mode Power: FULL) 0
 0xd180: (NIKON CSM Menu: Detailed) 1
 0xd190: (NIKON Bracketing Increment: 2.0) 12
 0xd1b0: (NIKON Low Light Indicator: No) 0
 0xd1c0: (NIKON Flash Open: No) 0
 0xd1c1: (NIKON Flash Charged: No) 0
# ptpcam --show-all-properties -v

Camera: D3300
 0x5001: (Battery Level) 100
 0x5003: (Image Size) "4496x3000"
 0x5004: (Compression Setting) 1
 0x5005: (White Balance: Automatic) 2
 0x5007: (F-Number: 1.8) 180
 0x5008: (Focal Length: 30mm) 3000
 0x500a: (Focus Mode) -32750
 0x500b: (Exposure Metering Mode: Multi-spot) 3
 0x500c: (Flash Mode) -32752
 0x500d: (Exposure Time: 0.0012s) 12
 0x500e: (Exposure Program Mode: Manual) 1
 0x500f: (Exposure Index (film speed ISO)) 6400
 0x5010: (Exposure Bias Compensation: 0.0) 0
 0x5011: (Date Time) "20150610T225551"
 0x5013: (Still Capture Mode: Normal) 1
 0x5018: (Burst Number) 1
 0x501c: (Focus Metering Mode) -32751
 0xd303: (UNKNOWN) 1
 0xd406: (UNKNOWN) "Windows/6.0.5330.0 MTPClassDriver/6.0.5330.0"
 0xd407: (UNKNOWN) 1


As you can see in the output some vendor extension modes are not recognized and are displayed as numeric values rather than descriptive text. However we can inspect such properties anyway:

# ptpcam -s 0x501c -v

Camera: D3300
Focus Metering Mode: [0x501c, readwrite, UINT16] 
 Current value: 0x8011 (-32751)
 Factory value: 0x8011 (-32751)
Enumerated:
0x0002 (2) [Multi-spot]
0x8010 (-32752)
0x8011 (-32751)
0x8012 (-32750)

Mind that you can use textual property names with abbreviations:

# ptpcam --set "Focus M" -v

Camera: D3300
Focus Mode: [0x500a, readonly, UINT16] 
 Current value: 0x8012 (-32750)
 Factory value: 0x8012 (-32750)
Enumerated:
0x0001 (1) [Manual]
0x8010 (-32752)
0x8011 (-32751)
0x8012 (-32750)
0x8013 (-32749)

# ptpcam --set "Focus Me" -v

Camera: D3300
Focus Metering Mode: [0x501c, readwrite, UINT16] 
 Current value: 0x8011 (-32751)
 Factory value: 0x8011 (-32751)
Enumerated:
0x0002 (2) [Multi-spot]
0x8010 (-32752)
0x8011 (-32751)
0x8012 (-32750)

Setting properties is as simple as it can be:

# ptpcam --set "Focus Me" -v --val 2

Camera: D3300
'Focus Metering Mode' is set to: 0x8011 (-32751)
Changing property value to 2 [Multi-spot] succeeded.

# ptpcam --set Image --val 6000x4000

Camera: D3300
'Image Size' is set to: "4496x3000"
Changing property value to 6000x4000 [(null)] succeeded.

# ptpcam -s 0x5005 --val 4

Camera: D3300
'White Balance' is set to: [Automatic]
Changing property value to 4 [Daylight] succeeded.

Power issues

The Ricoh Theta SC will work if directly connected to the Raspberry Pi USB - even with 5m of USB cable. HOWEVER, the Pi does not deliver enough power to charge, or maintain the charge , of the Theta SC over a long period of time, and will start to fuck up, with the following warning visible in /var/log/messages (output of dmesg):


I have tested this both with several different USB cables, short and long, including the USB cable that came with the camera. It would appear that the problem is insufficient voltage from the RPi. 

This is annoying. To get around the problem, we have to split the 5v power source to the camera from the USB data lines.


  • No labels