Problems using ptpcam on RPi with Theta SC via USB


#3

Update: I just found out that SC supports the USB API as well.

Can you do this:

$ ptpcam -i

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

If not, can you see the camera if you do this:

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

Example detecting camera with gphoto2

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

Please advise on version of Raspian and libptp you are using.

This is a known working configuration

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

In addition to your version of Raspian and libptp, please confirm that you’ve read the article below and can detect the camera with lsusb:


#4

Yes, SC does seem to support the USB API…

I just tried ptpcam -i again. Like before, it is now having that same error message regarding an inaccessible shared library (which I thought I had fixed as per my last comment using sudo ldconfig… I tried to re-run sudo ldconfig again but it’s no longer fixing that issue…

$ ptpcam -i
ptpcam: error while loading shared libraries: libusb-0.1.4: cannot open shared object file: No such file or directory

FYI, I have libusb-0.1.8 installed.

$ lsusb
Bus 001 Device 015: ID 0000:0538  
Bus 001 Device 007: ID 1c4f:0002 SiGma Micro Keyboard TRACER Gamma Ivory
Bus 001 Device 006: ID 148f:5370 Ralink Technology, Corp. RT5370 Wireless Adapter
Bus 001 Device 005: ID 0bda:5411 Realtek Semiconductor Corp. 
Bus 001 Device 004: ID 0bda:5411 Realtek Semiconductor Corp. 
Bus 001 Device 016: 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. 
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

lsusb can see the Ricoh Theta (bus 001, dev 016).
I note that the dev number changes whenever I either unplug and replug the camera in, or when I reboot the RPi. Is there a way of making this constant? (Is there a need?) I plan to take photos with the Theta via a cron job every five minutes - the whole system will be set up in a different country, so I can’t be there to reprogram it to use a different dev #… hopefully, that’s not going to be necessary.

$ gphoto2 --auto-detect
Model                          Port                                            
----------------------------------------------------------
USB PTP Class Camera           usb:001,016

I am currently using a Raspberry Pi 3 Model B, Raspbian Jessie, libptp2-1.2.0, and kernel v4.9.24-v7+. I note this is lower than your version 4.9.51-v7+. How can I go about updating this?

Thanks for your help. :smile:
David


#5

I had this problem a while ago. I’m trying to remember how I solved it…

When I first tried to run ptpcam, I got this error:

craig@linux-silver:~$ ptpcam
ptpcam: error while loading shared libraries: libptp2.so.1: cannot open shared object file:

I think it just started to work when I did the compile on Raspian Jessie. Though, obviously you’re having the same problem I was. To remember the steps, I’ll need to do a clean install.

In the meantime, you can see the config below of a working system.

if you do

ldd /path/to/you/ptpcam

is it pointing to the correct libraries and do you have them on your system?

You can also try cloning Koen Hufken’s repo and seeing if it installs libptp and ptpcam for you.


#6

Thanks for the advice. :slight_smile:

$ which ptpcam
/usr/local/bin/ptpcam

$ ldd `which ptpcam`
linux-vdso.so.1 (0x7ef8d000)
/usr/lib/arm-linux-gnueabihf/libarmmem.so (0x76fc0000)
libptp2.so.1 => /usr/local/lib/libptp2.so.1 (0x76f8f000)
libusb-0.1.4 => not found
libc.so.6 => /lib/arm-linux-gnueabihf/libc.so.6 (0x76e4e000)
/lib/ld-linux-armhf.so.3 (0x54b2f000)

$ ldd /usr/local/bin/ptpcam
linux-vdso.so.1 (0x7efcd000)
/usr/lib/arm-linux-gnueabihf/libarmmem.so (0x76f90000)
libptp2.so.1 => /usr/local/lib/libptp2.so.1 (0x76f5f000)
libusb-0.1.4 => not found
libc.so.6 => /lib/arm-linux-gnueabihf/libc.so.6 (0x76e1e000)
/lib/ld-linux-armhf.so.3 (0x54ade000)

I note it’s still complaining about not having libusb v0.1.4 installed.

I just installed libusb v0.1.4 from source (so I now have v0.1.4 and v0.1.8 installed on my system).

$ ldd /usr/local/bin/ptpcam
linux-vdso.so.1 (0x7ed37000)
/usr/lib/arm-linux-gnueabihf/libarmmem.so (0x76f59000)
libptp2.so.1 => /usr/local/lib/libptp2.so.1 (0x76f3c000)
libusb-0.1.4 => /usr/local/lib/libusb-0.1.4 (0x76f24000)
libc.so.6 => /lib/arm-linux-gnueabihf/libc.so.6 (0x76dcf000)
/lib/ld-linux-armhf.so.3 (0x54adf000)

That appears to be happy, at least… testing…

Ok, now ptpcam isn’t complaining about missing libraries. That’s a step forward! Thanks for your help with that.

Now continuing with the problems…

$ gphoto2 --auto-detect
Model                          Port                                            
----------------------------------------------------------
USB PTP Class Camera           usb:001,016 



$ lsusb
Bus 001 Device 015: ID 0000:0538  
Bus 001 Device 007: ID 1c4f:0002 SiGma Micro Keyboard TRACER Gamma Ivory
Bus 001 Device 006: ID 148f:5370 Ralink Technology, Corp. RT5370 Wireless Adapter
Bus 001 Device 005: ID 0bda:5411 Realtek Semiconductor Corp. 
Bus 001 Device 004: ID 0bda:5411 Realtek Semiconductor Corp. 
Bus 001 Device 017: 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. 
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub


$ ptpcam -l

Found no PTP devices

$ ptpcam -i

Camera information
==================
could not find any device matching given bus/dev numbers

So ptpcam still isn’t detecting the Theta…
Just to check, I also tested:

$ gphoto2 --capture-image-and-download 
New file is in location /store_00010001/DCIM/100RICOH/R0010104.JPG on the camera
                                                                               
*** Error ***              
PTP I/O Error
ERROR: Could not get image

Interesting. This was working before… I’ll run it again…

$ gphoto2 --capture-image-and-download 
New file is in location /store_00010001/DCIM/100RICOH/R0010105.JPG on the camera
Saving file as R0010105.JPG                                                    
Deleting file /store_00010001/DCIM/100RICOH/R0010105.JPG on the camera

After running ls, I can confirm that file copied over to the RPi… gphoto2 seems to be working fine now! Don’t know why gphoto2 had that temporary issue. I changed nothing, I literally tried it twice in a row, not running any other commands in between.

In any case, ptpcam still isn’t working…

You can also try cloning Koen Hufken’s repo and seeing if it installs libptp and ptpcam for you.

Sorry to be a complete noob, but could you please explain how to do this?
EDIT: never mind, I see the link at the bottom of your post. I glossed over that, assuming it was a forum post signature. Silly me! I’ll install that now and will report back.

EDIT 2: Ok, ran the installer script, and this happened:

(there was a bunch of apt-get install responses; here are the last few lines of output....)
install_photosphere.sh: 26: install_photosphere.sh: [[: not found
install_photosphere.sh: 34: cd: can't cd to /root/libptp/
install_photosphere.sh: 35: install_photosphere.sh: ./configure: not found
sudo: ./make: command not found

I initially ran this as user Pi, but had permissions errors, so the second time around ran it as sudo. That’s when the above happened.

I then did some testing, just in case it had fixed things somehow:

$ ptpcam -l

Found no PTP devices

So still no joy, sadly.

Thanks for your help and time with this. I appreciate it heaps. Hopefully, we’ll find an answer. :slight_smile:


#7

Thanks for the detailed results from your tests. I think other people from the community will also benefit. I’m going to do a clean install onto a different Raspberry Pi.

I had the same problem as you and I fixed it, but I can’t remember what I needed to do. I went through my notes and it goes from having the problem to happily using ptpcam, with no documentation on what I did to solve the problem. As I’ve solved it a few times, I think my memory will come back as I’m going through the install and configuration.

I tried to do this last night, but ran out of time. There’s a new camera, the THETA V, out and there’s a bunch of testing I want to do with the live streaming and 4K video files. The THETA V uses the same USB API and the still image resolution is the same, so I’ll do my test with the THETA V.

I think the problem is with the right mix of the libaries.


#8

I was able to replicate and fix the problem.
try this:

$  sudo bash
# export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib

all the ptpcam commands worked, including start/stop video, take picture, download picture and video. able to set all the options.

To get that working permanently, I added it to my .bashrc and it worked after rebooting. You can also try adding it to /etc/environment (which I didn’t try, but think should work).

I’m still planning to document the full install in the future.

I think your problem is with the LD_LIBRARY_PATH

Also, I needed to run as root in my last test (use sudo bash)

I documented the full process here:


#9

Howdy!

Thanks for the testing and for offering that solution. Unfortunately, it doesn’t fix my problems…:

pi@v2iOTS1:~ $ sudo bash
root@v2iOTS1:/home/pi# export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib
root@v2iOTS1:/home/pi# ^C
root@v2iOTS1:/home/pi# exit
pi@v2iOTS1:~ $ ptpcam -i
ptpcam: error while loading shared libraries: libusb-0.1.4: cannot open shared object file: No such file or directory
pi@v2iOTS1:~ $ export LD_LIBRARY_PATH=/lib:/usr/lib:/usr/local/lib
pi@v2iOTS1:~ $ ptpcam -i

Camera information
==================
could not find any device matching given bus/dev numbers

Running the command you suggested actually broke ptpcam even further. But running
export LD_LIBRARY_PATH=/lib:/usr/lib:/usr/local/lib
reverted things to how I had them in my last comment (i.e. ptpcam is partially working now, but just not detecting the Theta).

This is interesting:
ptpcam: error while loading shared libraries: libusb-0.1.4: cannot open shared object file: No such file or directory
…because I just installed that, as detailed in my last comment. :face_with_raised_eyebrow:

If I apply your proposed fix, and then do ldd which ptpcam:

pi@v2iOTS1:~ $ sudo bash
root@v2iOTS1:/home/pi# export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib
root@v2iOTS1:/home/pi# ptpcam -i
ptpcam: error while loading shared libraries: libusb-0.1.4: cannot read file data: Error 21
root@v2iOTS1:/home/pi# sudo ptpcam -i
ptpcam: error while loading shared libraries: libusb-0.1.4: cannot open shared object file: No such file or directory
root@v2iOTS1:/home/pi# ^C
root@v2iOTS1:/home/pi# exit
pi@v2iOTS1:~ $ ldd `which ptpcam`
linux-vdso.so.1 (0x7edd2000)
/usr/lib/arm-linux-gnueabihf/libarmmem.so (0x76fdc000)
libptp2.so.1 => /usr/local/lib/libptp2.so.1 (0x76fbf000)
libusb-0.1.4 => /usr/local/lib/libusb-0.1.4 (0x76fa7000)
libc.so.6 => /lib/arm-linux-gnueabihf/libc.so.6 (0x76e52000)
/lib/ld-linux-armhf.so.3 (0x54b13000)

…bizarre. It’s detecting libusb-0.1.4 as being installed…


#10

In my test today, I’m running libusb-1.0.21

  1. I needed to install libudev-dev with

     sudo apt-get install libudev-dev
    
  2. compile and install libusb-1.0.21 from source
    then

  3. compile and install libptp2-1.2.0 from source

  4. in my case after this, I needed to set LD_LIBRARY_PATH to include /usr/local/lib

  5. After that, I needed to run the ptpcam command as root

Is it possible that you compiled libptp and ptpcam against an old version of libusb?

I think you’re close to the finish line.


#11

I needed to install libdev-dev with

sudo apt-get install libdev-dev

Errr… do you mean libusb-dev? If so, I’ve already got it installed. :slight_smile:

compile and install libusb-1.0.21 from source

Done, without problems.

then

compile and install libptp2-1.2.0 from source

During the “make” phase of this process, I got a few errors:

Assembler messages:
Fatal error: can't create .libs/ptp.o: Permission denied
Makefile:493: recipe for target 'ptp.lo' failed
make[2]: *** [ptp.lo] Error 1
make[2]: Leaving directory '/home/pi/libptp2-1.2.0/src'
Makefile:386: recipe for target 'all-recursive' failed
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory '/home/pi/libptp2-1.2.0'
Makefile:317: recipe for target 'all' failed
make: *** [all] Error 2

(running sudo make seemed to work though)

in my case after this, I needed to set LD_LIBRARY_PATH to include /usr/local/lib

For the sake of being thorough with the documentation, to do this I ran:

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

Then Ctrl+D to get back to the normal shell.

After that, I needed to run the ptpcam command as root

That’s odd. I can now run ptpcam -i without running as root and it WORKS!!! :smiley:

Is it possible that you compiled libptp and ptpcam against an old version of libusb?

Quite likely. I was following instructions from about a dozen different guides, each of which said to use a different version…!

FANTASTIC! IT’S WORKING!!! :slight_smile:

Thank you so much for all your help with getting this going for me. I truly appreciate it!


#12

Wonderful news. Thanks for reporting back. I’m sure your experience will also help others.

Just so you know, I only needed to run ptpcam as root to download the images and video files from the camera. Everything else ran as the default user.

I’m working on guide with a fresh version of Raspbian.

Correction:

I needed to install libudev-dev with

 sudo apt-get install libudev-dev

I needed this to configure libusb-1.0.21.

The previous post had a typo and said, “libdev-dev”. I just corrected the post.


#13

David,

I like the ALL CAPS announcement that it’s working. :slight_smile: What are you building? What made you want to use USB over wifi?

Jesse


#14

Hi Jesse,

I am building a camera network across Australia and New Zealand for monitoring the Aurora Australis for the Southern Hemisphere Aurora Group on Facebook.

You can see the current images (built using Raspberry Pi’s and RPi cameras) here, if you’re interested: https://ionthesky.huntergeophysics.com/test.php

I’m now looking at switching to the Theta as it provides a 360-degree view (useful for monitoring cloud cover, which obviously blocks the view of aurora), and because it is capable of long-exposure photographs at high ISO (vital for imaging very weak aurora.

I need to use USB over WiFi because the Raspberry Pi’s cannot connect to both the local WiFi network (to upload the images to my server) and connect to the Theta simultaneously (even when you have two separate USB WiFi adapters). The RPi 3 and RPiZ Wireless do have Bluetooth, but the RPi BT module can only connect to certain devices (e.g. headphones); it cannot be used for connecting to generic BT devices such as COM ports or the Theta camera. So USB was the only way to go.

By the way, we had a very strong aurora here last night - managed to get some really fantastic images with the Theta V I’m prototyping with…


#15

David,

I was able to have the Raspberry Pi Zero W connect to a Theta S and at the same time act as an access point and host a Web server, File Server and SSH connection via a second WIFI module with the Litle Black Box project.

Little Black Box and Mini Little Black Box

Let me know if you have any questions that are not answered in the above thread.

Bob


#16

Hi Bob,

The main issue is that it’s not possible to manually set the subnet for the Theta. My original cameras (RPi’s only, no Thetas) use WiFi networks and the RPi is taped onto windows inside people’s houses. I am essentially mooching off people’s own WiFi networks.

An option is to change the subnet on the WiFi router, so that it isn’t the same as the Theta’s subnet. That would then allows to simultaneous WiFi network connections. However, the logistics of changing WiFi router settings on someone’s router from a different country, when the hosts (most of the time) aren’t all that computer-literate, makes that nigh-on impossible.

Basically, the above (which was admittedly difficult) was actually easier than using WiFi only.

Plus the USB cable is - of course - faster than WiFi for file transfer…

How did you manage to connect your RPi to two WiFi networks simultaneously? Did you just change subnet values?

Thanks for the suggestion. I’ve also commented directly on your post about Theta V temperatures…

By the way, here’s an earlier discussion I had on the RPi forum about the dual WiFi network issue I faced that may give insight into my way of thinking… https://www.raspberrypi.org/forums/viewtopic.php?f=29&t=190525

Cheers!

David


#17

Dave,

I have the PiZero connect to the Theta at 192.168.1.1 without connecting to the host network at all. I then set up an access point for the PiZero’s external WIFI module and use an IP that is not normally used in Home Networks.

So now we have a standalone system and the problem you would have to solve is a bridge from the host’s internet router to your stand-alone system. Perhaps a GL-Inet $20 router configured as a bridge.

auto wlan0
allow-hotplug wlan0
iface wlan0 inet manual
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf # Theta connection goes in wpa_supplicant.conf

allow-hotplug wlan1
iface wlan1 inet static
address 192.168.55.1 #Ip used for the Pi Zero access point connection
netmask 255.255.255.0

Bob


#18

Ahhhh ok. That makes sense.

Thanks for clarifying.


#19

Are you planning to pre-configure a set of microSD cards and ship them to your user base with ptpcam installed?

I don’t know how to make a Raspbian system image, but if someone did, it would be nice to put the entire image up on a repository with ptpcam, libptp, and libusb pre-installed and tested. That way, someone could just get the image, install it on a microSD card and then modify their program on top of it. It would be good to pre-install tlapser and Koen’s Photosphere project. The short-term solution to help people is to document the install process.

The other piece of the pre-configured microSD card would be to install some type of server to show all the beautiful images. There’s some really nice images in your group.


#20

I don’t know how to make a Raspbian system image, but if someone did, it would be nice to put the entire image up on a repository with ptpcam, libptp, and libusb pre-installed and tested.

I was planning to do this, actually. It’s on the to-do list for further down the track, though, once it’s all been tested properly…

Is there somewhere in particular you’d want the disk image to be hosted?

The other piece of the pre-configured microSD card would be to install some type of server to show all the beautiful images.

Yeah… I’m not really all that familiar with setting up web servers, especially not on an RPi. But it certainly could be done…

By the way… I realise this is going off-topic from my original post, but… you guys are the only people responding to my support requests, anywhere on the Internet… :stuck_out_tongue:

I sent a Theta V to a friend further south than I am and he got a heap of photos with aurora in them the other night.
There is a screenshot I have taken from a timelapse he compiled, which shows the problem I’m now facing…

Screenshot here: https://www.dropbox.com/s/vkfo2wmfk40wga4/ThetaVAuroraRedHemisphereExample.png?dl=0

All images I (or my friend) have taken with the Theta V have this strange discolouration to them in one hemisphere (i.e. as if one lens is faulty). As you can see from the screenshot, there is a clear vertical line, with one half of the sphere having a red tinge to it (to the right of the screenshot). (The left half of the screenshot shows a dull aurora and some town lights).

Has anyone else experienced this issue? It may be a long-exposure issue - this image was taken at ISO 2000, 30 sec.

My own photos from last week with the same camera (similar exposure settings) had the same issue.

Admittedly, these images were taken using the Theta app, not via ptpcam, and so are using the Theta app white balance presets, rather than a manually-defined colour temperature (through ptpcam). So I’m hoping that may be the cause of the problem. I’m still waiting to get the camera back from my friend before I can do any testing of my own.

For what it’s worth, I didn’t have this problem when I was testing the Theta SC a few months ago. Perhaps I’ve got a bodgy Theta V and should send it back under warranty?


#21

Is the aurora photo processed through something like photoshop? Or is that the original image taken from the THETA with no processing? Certain filters on Photoshop will cause this problem. If it’s the raw image, try to align the edge of the camera toward the largest bright spot when the shot is taken. It seems like either the image was processed with a filter or there is a problem with the camera.

Are you using the newest firmware? The firmware can be upgraded with the desktop application.

If you have a Raspbian image, we can put it on the theta360developers GitHub repo in addition to other places to make it easier for people to find.

I’ll look into the image problem a bit more.

Thanks for all your work on this. Super cool project and would love to see more beautiful pictures.

This was the update on the firmware. See note about still image joining accuracy.

Oct. 24, 2017 Version 1.10.1

  • The precision of video slant top/bottom correction has been improved.
  • Still image joining accuracy has been improved.
  • The quality of the still image is improved by modifying the compression ratio.
  • Corrected bugs and improved performance.

Info on updating the firmware is here.


#22

David,

Wow, that would be a fantastic contribution if you built a pre-tested image… well, pre-used… Pre-tried out… Whatever you want to call it, and made it available to everyone. We host quite a few repos on the Unofficial Guide GitHub account. We could easily host it there.

Seriously cool.

Jesse