Theta V + raspberry pi - Schedule snapshot and ftp to server

Hi

It is possible to schedule the Raspberry pi take a stitched photo from the Theta V via usb and send this by FTP?

If so, any tutorial or clues?
Appreciate any help!

Regards
Kristian

It’s covered in this video tutorial series, but I just realized that I have so much content scheduled that the video is scheduled for June 4. It uses scp with keys, but the concept is the same.

This other playlist has related information.

This may be useful.

Example

Feel free to ask more questions.

Also, please provide information on your platform

  • whether scp is okay instead of sftp
  • where are you transferring the files to (such as Linux cloud server)
  • how are the users getting the files once it is on the server (such as web browser)

The information may help us to point you in the right direction.

Thank you for your replay!

Due to limited dataplan I’m planning to let the Raspberry pi take a stitched photo from the theta V and upload this to an server every five minute. The server is either private hosted or cloud hosted. I’m flexible regards the transfer method.
The photo should be shown on a website for the public.

Is this an task covered by the videos you attached?

Regards
Kristian

1 Like

technique if you connect Raspberry Pi with Wi-Fi, not with USB cable

Please advice if you want to use the USB cable to send the API commands.

download theta testing tool

Get the tool we use for testing at this site:

Get the file raspberry_pi_theta.zip

image

transfer to Raspberry Pi and unzip

It is best to download it from a desktop Mac/Linux/Windows computer and then transfer it to the Raspberry Pi as the RPi browser is slow on my system.

Once the file is on the RPi, unzip the files.

go into script_examples directory

image

use text editor to modify the file take_and_upload

image

  • change the for loop to the number of pictures you want to take and upload example {1..500} will take 500 pictures and upload each picture
  • comment out sleep 10s and uncomment sleep 5m. A comment has a # mark in front of it
  • set up ssh keys on both the server you have the HTTP server on as well as your RPi
  • set up the HTTP server to grab the images from the appropriate directory you will scp to
  • change the server address to the address of your ip server
  • change the username and path to the credentials for your server

snippet of script - NOT the full script

echo start timelapse photography loop test
# example of loop to take 2 pictures for timelapse
# increase the number 2 below to 300 to take 300 pictures
# example {1..300}
for counter in {1..5}
do
    ./theta takeAndDownload
    echo that was picture $counter
    ((counter++))
    # if you want to have the timelapse space 30s apart
    echo waiting 10 seconds for the next shot
    sleep 10s
    # if you want to take a shot every 5 minutes
    # sleep 5m
done
echo timelapse done

# grab all the thumbnails and write to local storage
./theta download --thumb=all
echo thumbnail download test completed
echo *** Will Start Upload to Digital Ocean Hosting ***
scp -r *.JPG craig@45.55.31.80:/home/craig/robot/
echo completed upload
echo go to http://45.55.31.80/robot/ to view images

let the community here know how it goes :slight_smile:

Other

If you are making a video on the server, you may want to disable topbuttomcorrection

1 Like

Hi

I have just ordered my Theta V and I will start testing this as soon I got it.
Thank you for all your help!

Kristian

Just to recap, there are two different ways to connect the Raspberry Pi and the RICOH THETA:

  1. USB cable
  2. Wi-Fi

The software and APIs are different in each case. The THETA V can handle both methods.

The USB API is more difficult to set up. If you can use the Wi-Fi API, it might be better, especially initially. You will need to disable auto-power off and auto-sleep in the camera.

For long-term use, most people use the USB API, but as it could be more difficult for you to set up, it might be good for phase 2 of your project.

The choice depends on your goal and how much time you’re able to spend with configuration.

Hi craig

You are spot on!

I will try the “easy” method with wifi, as you explained, first. But at the end maybe try to get the USB API to work for a more stable setup.

Kristian

2 Likes

If you use the Wi-Fi API, there are two methods:

  1. AP mode where the camera is always at 192.168.1.1
  2. Client Mode where the camera is assigned an IP by your Internet router

I suggest you use AP mode. If you use Client Mode, you must use Digest Authentication, which is possible, but not covered with our test application.

If you use AP mode (recommended approach to start with), then your Raspberry Pi must have two network interfaces (such as an onboard Wi-Fi plus an USB Wi-Fi adapter).

In this configuration, your Internet router must not be at 192.168.1.1. If your Internet router is at the same IP address as the camera, the RPi will not be able to find the camera reliably. You will need to change the IP address of your router or set up a different router for your RPi network.

With two network interfaces, you may need to manually set up the routes on the Raspberry Pi the first time. To help with configuration, you may need to plug a monitor and keyboard onto the raspberry Pi and see how the network routing is setup initially. Once you set up the network routing for each interface manually and verify that it works, then go back and create a script to automate this at startup.

As there is a large RPi community, you can likely find detailed up for the RPi network route setup on the RPi forums.

If you have time, please post your progress on this forum. There is a good body of knowledge here on the camera API, but we are not that familiar with the RPi. It will be good to get more RPi project builds. :slight_smile: :theta: :hammer_and_wrench: :clamp: :theta_s:

Hello,

You can use gphoto2 to take photo (equirectangular) via USB and download the picture on the Rpi. Sending it to a ftp should be done on the Rpi in a second step

Here is an example how to take picture and download it via command line. Note that the picture is not deleted from the theta. This command line is executed in a python program but use your prefered language

gphoto2 --set-config=/main/other/5013=1 --capture-image-and-download --filename “/home/pi/photo.jpg” --force-overwrite

You may need to configure the photo parameters in a previous step and switch to photo mode

Hugues

2 Likes

Nice tip!

What does the config below set?

I don’t normally use gphoto2 on Raspberry Pi, but I will try using it more now. :slight_smile:

1 Like

Hi

I finally got some time to try to get my project going.

My Theta V is connected to the Rpi via USB-cable. And I use this code to take a photo and upload it to a ftp-server.

sudo gphoto2 --set-config=/main/other/5013=1 --capture-image-and-download --filename /home/pi/Pictures/photo.jpg --force-overwrite
curl -T /home/pi/Pictures/photo.jpg ftp://ftp_server_adress//www/photo.jpg --user username:password

But I have some questions;

*Is it possible to chage the picture quality or size, either from camera or in the code?

*Can I remove the battery from the Theta V so the camera is just powered from the Rpi?
So the camera will start and shut off when the Rpi is started/shut off?

*Can gphoto2 also be used with the Theta SC2?

Regards
Kristian

yes.

If you want greater control of the image size on the RPi before you transfer it, use something like ImageMagick on the RPi before you push the images up to your server.

You cannot remove the battery and power it from the Raspberry Pi, at least not easily. You would need some additional electrical skills and would likely need to add a resistor to the THETA V power circuit to compensate for the battery not being there. There are no working directions on this process, but there are “it should work in theory” instructions if you’re interested in a hobby hack and have time. Let me know if you want me to search for that info on the electrical characteristics of the power circuit.

You can turn the THETA V off with the RPi.

Notice of website closure

$ ptpcam -R 0x1013

You can power it on by cycling the power on the USB ports. Let me know if you want details on this.

If you turn the RPi on, the V will turn on through the USB cable.

yes.

The SC2 and the V are slightly different, but the USB API is the same specification. There may be some differences in actual use. If you buy an SC2, buy it from a place with a return policy just in case it does not perform as expected.

Hi

Thank you for all your help!

I have now manage to resize and timestamp the photo with ImageMagic! I’m very happy with that! :slight_smile:

My focus now is the powering of the camera. I’ts important for my project that I manage to power the camera on/off with the power from the USB.
So if there is any directions how to do this I will appreciate some info!

1 Like

Thank you for the update.

Power off

$ ptpcam -R 0x1013

Power On with Raspberry Pi

Camera - RICOH THETA Development on Linux

Power On Jetson Nano

Camera - RICOH THETA Development on Linux

If you are using a Raspberry Pi 4

Camera - RICOH THETA Development on Linux

If you are using x86 and willing to cycle USB ports

You may be able to use the same technique used on the Raspberry Pi.

https://github.com/codetricity/hub-ctrl.c


Note that wake from sleep is not currently working with the V, but does work from the Z1.

Hi Craig

I have tried your solution for power on the Theta V with Raspberry Pi. But my lack of knowledge of programming of the pi I need some guidence how to do this.

I will appreciate if you can explain the process step by step.

Kristian

For the V, I don’t think you can change the image resolution.

Notice of website closure

There is no known way to remove the battery from the V and have it turn on like a webcam when the Raspberry Pi is turned on. You can:

  1. wake the camera from sleep with the raspberry pi
  2. power on the THETA V from a power off state.

Plug the camera into the Raspberry Pi when the camera is off. Then, you will see that it turns on.

I believe that gphoto2 will work with the SC2.

If you can download the files to the Raspberry Pi with the USB cable, you can reduce the file size on the RPi.

Additional examples of processing with GraphicsMagick, which is like ImageMagick.

The idea is for you to write a bash script for the RPi that uses ImageMagick to reduce the file size before you transfer it to the cloud.

Hi,

Thank you for all your help!

For the problem with the powering the theta from the Rpi, it this I need help with…
Can you direct me further?

image

Please confirm that the camera is in a power off mode and not in sleep mode. If you are trying to wake it up from sleep, there is additional information I can send. If you are turning it on from a power off state, see the tip below from Shun Yamashita of fulldepth.

Additional Tips for Raspberry Pi 4

Thanks to Shun Yamashita of fulldepth for this solution to cycle the power on the Raspberry Pi 4 USB ports, which has the effect of turning the THETA Z1 on when it is plugged in with a USB cable.

Shun reported that with the Raspberry Pi 4, the script above did not work. He wrote the script below for the RPi 4 which does work.

#!/bin/bash

ptpcam -R 0x1013

/usr/local/bin/hub-ctrl -h 0 -P 1 -p 0
/usr/local/bin/hub-ctrl -h 0 -P 2 -p 0
/usr/local/bin/hub-ctrl -h 0 -P 3 -p 0
/usr/local/bin/hub-ctrl -h 0 -P 4 -p 0
/usr/local/bin/hub-ctrl -h 1 -P 1 -p 0
/usr/local/bin/hub-ctrl -h 1 -P 2 -p 0
/usr/local/bin/hub-ctrl -h 1 -P 3 -p 0
/usr/local/bin/hub-ctrl -h 1 -P 4 -p 0
/usr/local/bin/hub-ctrl -v

sleep 5

/usr/local/bin/hub-ctrl -h 0 -P 1 -p 1
/usr/local/bin/hub-ctrl -h 0 -P 2 -p 1
/usr/local/bin/hub-ctrl -h 0 -P 3 -p 1
/usr/local/bin/hub-ctrl -h 0 -P 4 -p 1
/usr/local/bin/hub-ctrl -h 1 -P 1 -p 1
/usr/local/bin/hub-ctrl -h 1 -P 2 -p 1
/usr/local/bin/hub-ctrl -h 1 -P 3 -p 1
/usr/local/bin/hub-ctrl -h 1 -P 4 -p 1
/usr/local/bin/hub-ctrl -v