Using USB API (MTP) with libghoto2 and Python bindings on MacOS, Raspberry Pi, Linux, ROS

If you put your code up on GitHub, please put the link here. I’m going to run tests with gphoto2 myself next week. Thanks.

Update Sept 9, 2020

I need advice on how to set the values of the camera with the Python API. If I change the camera to video mode, the value changes, but the camera does not actually shift into video mode.

The same command works from the command line. I think I need help with the basic syntax of using the gphoto2 Python module.

import gphoto2 as gp

MODE = '5013'
STILL_IMAGE = '1'
MOVIE =  str(int('0x8002', 0))

camera = gp.Camera()

camera.init()
mode = camera.get_single_config(MODE)
mode.set_value(MOVIE)
camera.exit()
1 Like

It’s been a while, @mhenrie.
I finally tried your code after all sorts of messes, but I got an error.
Can you guess the cause?

Setting camera to Manual exposure program
Traceback (most recent call last):
File “/test_mhenrie_code.py”, line 234, in
_unittest()
File “/test_mhenrie_code.py”, line 210, in _unittest
camera.init()
File “/test_mhenrie_code.py”, line 116, in init
raise RuntimeError(‘Unable to determine shutter speed options; restart app’)
RuntimeError: Unable to determine shutter speed options; restart app

Unfortunately, @craig’s code also gives me an error, although I don’t know why.
Maybe the path is wrong?

Traceback (most recent call last):
File “/test_craig_code.py”, line 10, in
mode = camera.get_single_config(MODE)
gphoto2.GPhoto2Error: [-6] Unsupported operation

Can you run the code in the examples directory of python-gphoto2 on GitHub?

In particular, does this work?

https://github.com/jim-easterbrook/python-gphoto2/blob/master/examples/camera-summary.py

$ python camera_summary.py 
WARNING: gphoto2: (gp_port_set_error [gphoto2-port.c:1190]) The supplied vendor or product id (0x0,0x0) is not valid.
Summary
=======
Manufacturer: Ricoh Company, Ltd.
Model: RICOH THETA Z1
  Version: 1.50.1
  Serial Number: 10010104
Vendor Extension ID: 0x6 (1.10)

Hugues mentioned that a modification to this file might help.

https://github.com/gphoto/libgphoto2/blob/master/camlibs/ptp2/config.c

I have not tried his fix yet.

Some of the commands seem to work.

$ python list_files.py 
WARNING: gphoto2: (gp_port_set_error [gphoto2-port.c:1190]) The supplied vendor or product id (0x0,0x0) is not valid.
File list
=========
/store_00020001/DCIM/100RICOH/R0010002.JPG
/store_00020001/DCIM/100RICOH/R0010003.JPG
/store_00020001/DCIM/100RICOH/R0010004.JPG
/store_00020001/DCIM/100RICOH/R0010005.JPG

Information on building libgphoto2 from source is here:
https://github.com/gphoto/libgphoto2/blob/master/INSTALL

I was able to build it from source.

At the current time, I am using ptpcam, which seems to work okay for my uses.

My goodness, that’s a lot more sample programs than I checked!
I might be able to develop some of this myself.

Aside from that, I ran camera-summry.py and it looked like below.

WARNING: gphoto2: (foreach_func [gphoto2-port-info-list.c:237]) Error during assembling of port list: 'Unspecified error' (-1).
WARNING: gphoto2: (gp_port_set_error [gphoto2-port.c:1186]) The supplied vendor or product id (0x0,0x0) is not valid.
Summary
=======
Manufacturer: Ricoh Company, Ltd.
Model: RICOH THETA V
  Version: 3.40.1
  Serial Number: 00153573
Vendor Extension ID: 0x6 (1.10)

Capture Formats: 
Display Formats: Association/Directory, JPEG, MP4, Firmware
Supported MTP Object Properties:
	Association/Directory/3001: dc01/StorageID dc02/ObjectFormat dc04/ObjectSize dc0b/ParentObject dc41/PersistantUniqueObjectIdentifier dc44/Name
	JPEG/3801: dc01/StorageID dc02/ObjectFormat dc03/ProtectionStatus dc04/ObjectSize dc07/ObjectFileName dc08/DateCreated dc09/DateModified dc0b/ParentObject dc41/PersistantUniqueObjectIdentifier dc44/Name dc87/Width dc88/Height
	MP4/b982: dc01/StorageID dc02/ObjectFormat dc03/ProtectionStatus dc04/ObjectSize dc07/ObjectFileName dc08/DateCreated dc09/DateModified dc0b/ParentObject dc41/PersistantUniqueObjectIdentifier dc44/Name dc87/Width dc88/Height
	Firmware/b802: dc01/StorageID dc02/ObjectFormat dc04/ObjectSize dc0b/ParentObject dc41/PersistantUniqueObjectIdentifier dc44/Name

Device Capabilities:
	File Download, File Deletion, No File Upload
	Generic Image Capture, Open Capture, No vendor specific capture

Storage Devices Summary:
store_00020001:
	StorageDescription: None
	VolumeLabel: None
	Storage Type: Builtin RAM
	Filesystemtype: Digital Camera Layout (DCIM)
	Access Capability: Read-Write
	Maximum Capability: 21088788480 (20111 MB)
	Free Space (Bytes): 19082989568 (18198 MB)
	Free Space (Images): 4549

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] value: 0
Image Size(0x5003):(readwrite) (type=0xffff) Enumeration [
	'5376x2688'
	] value: '5376x2688'
White Balance(0x5005):(readwrite) (type=0x4) Enumeration [2,4,32769,32770,6,32800,32771,32772,32773,32774,32775,32776] 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)
Date & Time(0x5011):(readwrite) (type=0xffff) '20200925T020641+0900'
Pre-Capture Delay(0x5012):(readwrite) (type=0x6) Range [0 - 10000, step 1000] value: 0.0s (0)
Still Capture Mode(0x5013):(readwrite) (type=0x4) Enumeration [1,3,32770,32772,32773,32774,32775] value: Single Shot (1)
Timelapse Number(0x501a):(readwrite) (type=0x4) Range [0 - 9999, step 1] value: 0
Timelapse Interval(0x501b):(readwrite) (type=0x6) Range [4000 - 3600000, step 1000] value: 4000
Audio Volume(0x502c):(readwrite) (type=0x6) Range [0 - 100, step 1] value: 100
Property 0xd006:(read only) (type=0x6) 0
Property 0xd00f:(readwrite) (type=0x8) Enumeration [0] value: 0
Perceived Device Type(0xd407):(read only) (type=0x6) 1
Property 0xd801:(readwrite) (type=0xffff) '(null)'
Property 0xd803:(readwrite) (type=0x4) Range [0 - 65534, step 1] value: 180
Property 0xd805:(readwrite) (type=0xffff) 'THETAYL00153573.OSC'
Property 0xd806:(readwrite) (type=0xffff) '00153573'
Property 0xd808:(read only) (type=0x2) Enumeration [0,1,2,3,4] value: 0
Property 0xd809:(read only) (type=0x4) Range [0 - 1499, step 1] value: 0
Property 0xd80a:(read only) (type=0x4) Range [0 - 1500, step 1] value: 0
Property 0xd80b:(readwrite) (type=0x2) Enumeration [0,1,2,3,4] value: 0
Property 0xd80c:(read only) (type=0x2) Enumeration [0,1,2] value: 1
Property 0xd80d:(read only) (type=0x4) 8098
Property 0xd80e:(readwrite) (type=0x2) Enumeration [0,1] value: 0
Property 0xd812:(readwrite) (type=0x0) Undefined
Property 0xd813:(readwrite) (type=0x4) Range [2500 - 10000, step 100] value: 5000
Property 0xd814:(readwrite) (type=0x2) Enumeration [0,1] value: 0
Property 0xd815:(readwrite) (type=0xffff) 'THETAYL00153573'
Property 0xd816:(readwrite) (type=0xffff) '00153573'
Property 0xd817:(readwrite) (type=0x4) Enumeration [1] value: 1
Property 0xd818:(readwrite) (type=0x4) Enumeration [1,2] value: 1
Property 0xd81a:(readwrite) (type=0x2) Enumeration [0,1] value: 0
Property 0xd81b:(readwrite) (type=0x6) Range [0 - 2592000, step 60] value: 64980
Property 0xd81c:(readwrite) (type=0x2) Enumeration [0,1,2] value: 0
Property 0xd81d:(readwrite) (type=0x2) Enumeration [0,1] value: 0
Property 0xd81f:(readwrite) (type=0x2) Enumeration [0,1,2] value: 0
Property 0xd820:(readwrite) (type=0x2) Enumeration [0,1,2,3,4,5,6,7,8] value: 0
Property 0xd821:(readwrite) (type=0x2) Enumeration [0] value: 0
Property 0xd822:(read only) (type=0x4) 0
Property 0xd823:(readwrite) (type=0x4) Enumeration [300,1500] value: 1500
Property 0xd825:(readwrite) (type=0x2) Enumeration [0,1,2,3,4] value: 0
Property 0xd826:(readwrite) (type=0x4) Enumeration [200,250,320,400,500,640,800,1000,1250,1600,2000,2500,3200] value: 1600
Property 0xd829:(readwrite) (type=0x4) Enumeration [0] value: 0
Property 0xd82a:(readwrite) (type=0x2) Enumeration [0,1] value: 1
Property 0xd82c:(readwrite) (type=0x2) Enumeration [1,2,3] value: 2
Property 0xd831:(read only) (type=0xffff) 'ProgressRate:000'

and ran list_files.py

WARNING: gphoto2: (foreach_func [gphoto2-port-info-list.c:237]) Error during assembling of port list: 'Unspecified error' (-1).
WARNING: gphoto2: (gp_port_set_error [gphoto2-port.c:1186]) The supplied vendor or product id (0x0,0x0) is not valid.
File list
=========
/store_00020001/DCIM/100RICOH/R0010132.MP4
/store_00020001/DCIM/100RICOH/R0010133.MP4
/store_00020001/DCIM/100RICOH/R0010134.MP4
/store_00020001/DCIM/100RICOH/R0010135.MP4
/store_00020001/DCIM/100RICOH/R0010136.JPG
/store_00020001/DCIM/100RICOH/R0010137.MP4
/store_00020001/DCIM/100RICOH/R0010138.MP4
...
/store_00020001/DCIM/100RICOH/R0010132.MP4
/store_00020001/DCIM/100RICOH/R0010133.MP4
/store_00020001/DCIM/100RICOH/R0010134.MP4
/store_00020001/DCIM/100RICOH/R0010135.MP4
/store_00020001/DCIM/100RICOH/R0010136.JPG
/store_00020001/DCIM/100RICOH/R0010137.MP4
/store_00020001/DCIM/100RICOH/R0010138.MP4
File info
=========
image dimensions: 1920 960
image type: video/mp4
file mtime: 2020-09-02 19:55:11

Without any modifications, “gphoto2 --set-config-index shutterspeed=10” could not be executed correctly.

*** Error (-110: 'I/O in progress') ***                                        

For debugging messages, please use the --debug option.
Debugging messages may help finding a solution to your problem.
If you intend to send any error or debug messages to the gphoto
developer mailing list <gphoto-devel@lists.sourceforge.net>, please run
gphoto2 as follows:

    env LANG=C gphoto2 --debug --debug-logfile=my-logfile.txt --get-config shutterspeed

Please make sure there is sufficient quoting around the arguments.

Is this something that can be fixed by modifying as @Hugues pointed out, or did @Hugues get the same error?
Also, have you already put up an issue in Git with a fix for this issue? If you haven’t already, I can get it up. While doing the quote.
Or shall I fork it and make a pull request?

2 Likes

Hello,

I had the same error with gphoto2 installed from apt. The fix is working but you need to modify and recompile libgphoto2.
It will be nice if you make a pull request. Before that if someone could check the VendorID on others Theta cameras in order to make the correction for all the theta models.

Hugues

3 Likes

Thank you for all your work and insight.

  1. I changed the title of the topic to reflect the actual discussion which evolved beyond MacOS
  2. I added a note to the very top post from the “moderator” to let people know that the topic changed

I’ll also try and help test this. There’s been a new surge in interest in the USB API, possibly driven by the increased demand for virtual surveillance.

BTW, if anyone with a good business opportunity is looking to partner with a company with experience in the USB API and streaming, please check out the article on FOX Sewer Rover and consider contacting Hugues with a great business opportunity. :slight_smile: Note the followup posts covering his modifications.

@Hugues is the VendorID, the same as the VendorExtensionID?

From the MTP Specification.

If so, I can run it against the cameras I have. I believe the extension ID is 0x00000006 on all of them, but I can check. In the libptp source code, this ID is assigned to Microsoft.

Z1

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

V

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

SC2 for business

This is the same as the SC2. The firmware number is different, but everything else should be the same for our purposes.

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

@NaokiSato102, I have not looked into the GitHub pull request. Please proceed with your testing and I can try and support your efforts. To do a pull request, you’ll need to fork the project first and do the modification, then test the modifications, then do the pull request.

My status:

  • I have compiled libghoto2 from source with no problems on Ubuntu 20.04 on x86
  • I have not installed or tested it as I think I need to first uninstall my existing libghoto2 and I am afraid my system will stop working
  • I have not applied the modifications

My plan:

  • I’ll attempt to compile it from source on a Raspberry Pi. If it’s possible, I’ll experiment with the modifications
  • if it takes too long due to the size of the project, I will try a different computer or a VM.
  • I will report back here
3 Likes

I couldn’t get it to work with the lib I installed with apt, either. (summarized)

Thank you @Hugues for checking the behavior.
I’m going to try the following on Raspberry Pi 3B+ before I try it in the production development environment.

  1. Try it with a lib you got with apt (it’s expected to not work properly. Continue with the test in 3)
  2. Try with a modified lib in a clean environment. (It is expected to work properly.)
  3. Uninstall the apt lib introduced in step 1, and try the modified lib. (Same as above.)

And if 2 and 3 go well, I’ll try it out in the production development environment.
I’ll make the transition between 1 and 2 by backing up the disk image.

Maybe the problem is that the lib that can be installed with apt is not updated to the latest version of git yet, and it works fine if you install it from the git source.
So I’m going to change the process to the following

  1. Try it with a lib you got with apt (it’s expected to not work properly. Continue with the test in 4)
  2. Try it with a lib you got with git (it’s expected to not work properly.)
  3. Try with a modified lib in a clean environment. (It is expected to work properly.)
  4. Uninstall the apt lib introduced in step 1, and try the modified lib. (Same as above.)

@mhenrie 's program on Ras-pi

What ?! Of course I installed libgphoto2 and PygPhoto2.

Traceback (most recent call last):
File “huga.py”, line 13, in
import gphoto2 as gp
ImportError: No module named gphoto2

Probably because of the lack of a path. I’m too sleepy to come up with a solution.

20/09/27 Added because the problem has been solved.

I installed gPhoto2 in pip, which is pip3 and works fine in Python3.
However, I didn’t install it in pip2, so it didn’t work in Python2.
The un-numbered Python in raspberry pi refers to 2, so that’s why it didn’t work.

What a rudimentary error.

Also, after resolving this, I had the usual mount-related errors, and since this is a CUI environment and I couldn’t use the sequential unmounting method by gvfs-mount, which I often use in my environment, I solved it by removing gvfs-backends and got it running.

The conclusion is that the first experiment failed as expected.

According to this article, the reason why gvfs-mount is not available can be solved by apt install gvfs-dbg.

However, when I looked closely, I saw an error in a different area. The error occurred one step or line later than last time.

Traceback (most recent call last):
File “huga.py”, line 234, in
_unittest()
File “huga.py”, line 210, in _unittest
camera.init()
File “huga.py”, line 118, in init
fstop = self.other_config.get_child_by_name(F_NUMBER)
gphoto2.GPhoto2Error: [-2] Bad parameters

Thank you for all this great information.

  1. Do you have the file huga.py available somewhere so that we can test the same file?
  2. Can you provide more information on how you’re using gvfs-dbg. I am not familiar with this and would like to solve the problems I’m having when I use gvfs automount and libptp2 at the same time. Did you uninstall gvfs-backends and then install gvfs-dbg?
  3. Did you completely remove the gvfs packages that can be installed with apt?
  4. Are you building gphoto2 on your Raspberry Pi 3? Does it take a long time?

My status

  • I didn’t try this on a Raspberry Pi as I was worried it was going to take too long to to compile and test gphoto2.

I decided to remove gphoto2 from my x86 i7 system and install things from source.

$ df |grep gphoto2
/dev/loop18        16512    16512         0 100% /snap/gphoto2/8
$ snap remove gphoto2
gphoto2 removed
$ sudo apt remove libgphoto2-dev

In the newest version of libphoto2 from github, modified the code per hugues post.

$ make
$ sudo make install

No problems.

I installed gphoto2 from source.

$ gphoto2 --version
gphoto2 2.5.23.1
...
This version of gphoto2 is using the following software versions and options:
gphoto2         2.5.23.1       gcc, popt(m), exif, no cdk, no aa, no jpeg, no readline
libgphoto2      2.5.25         standard camlibs (SKIPPING lumix), gcc, ltdl, EXIF
libgphoto2_port 0.12.0         iolibs: disk ptpip serial usb1 usbdiskdirect usbscsi, gcc, ltdl, EXIF, USB, serial without locking
$ which gphoto2
/usr/local/bin/gphoto2

Tests

$ gphoto2 --list-cameras |grep 'Ricoh Theta'
	"Ricoh Theta (WLAN)" (TESTING)
	"Ricoh Theta m15 (PTP mode)"
	"Ricoh Theta S (PTP mode)"
	"Ricoh Theta SC (PTP mode)"

$ gphoto2 --get-config shutterspeed
Label: Shutter Speed                                                           
Readonly: 0
Type: RADIO
Current: Auto
Choice: 0 Auto
END
$ gphoto2 --set-config=/main/other/500e=4 
Label: Shutter Speed                                                           
Readonly: 0
Type: RADIO
Current: 1/60
Choice: 0 1/25000
Choice: 1 1/20000
Choice: 2 1/16000
Choice: 3 1/12500
Choice: 4 1/10000
Choice: 5 1/8000
Choice: 6 1/6400
Choice: 7 1/5000
Choice: 8 1/4000
Choice: 9 1/3200
Choice: 10 1/2500
...
$ gphoto2 --set-config=/main/other/500e=2
$ gphoto2 --get-config shutterspeed                 
Label: Shutter Speed                                                           
Readonly: 0
Type: RADIO
Current: Auto
Choice: 0 Auto

Overall Status

  • At the moment, I still don’t have python-gphoto2 working properly.

I’m not sure how it pulls the vendor and product id.

$ python list_files.py 
WARNING: gphoto2: (gp_port_set_error [gphoto2-port.c:1190]) The supplied vendor or product id (0x0,0x0) is not valid.

I can get the port and device from gphoto2 --autodetect

$ gphoto2 --auto-detect
Model                          Port                                            
----------------------------------------------------------
USB PTP Class Camera           usb:005,003     

However, the python library is showing 0x0, 0x0

$ gphoto2 --summary
Camera summary:                                                                
Manufacturer: Ricoh Company, Ltd.
Model: RICOH THETA Z1
  Version: 1.50.1
  Serial Number: 10010104
Vendor Extension ID: 0x6 (1.10)
  1. I left out the explanation, but huga.py is @mhenrie 's program.

  2. I was just wondering if installing gvfs-dbg would save me from having to uninstall gvfs-backs, but I haven’t tried that in this raspberry-pi environment.
    “gvfs-dbg was not installed in the production development environment where gvfs-mount -u {path}” was available.
    Instead, gvfs, gvfs-bin, gvfs-daemon, gvfs-fuse, and gvfs-lib(:arm64) were installed.
    Any of these have “gvfs-mount -u {path}” available, and that’s what’s important.
    You can unmount them by looking up bus,dev in Theta and typing
    gvfs-mount -u /run/user/1000/gvfs/mtp:host=%5B{bus}%2C{dev}%5D.
    Note that the string after “host=” means the URL encoded string of [{bus}:{dev}].
    Just for reference.
    I don’t know which gvfs* can do this, but I think you should include them all for now.
    (That’s an irresponsible statement.)

  3. gvfs-backends Just uninstalling it was enough.

  4. If you have a fast enough internet connection and a working environment that doesn’t put too much strain on your raspberry-pi, you’ll be set up in no time. Because all you have to do is sudo apt install libgphoto2 and pip install gphoto2.
    I just uninstall gvfs-backends if needed.
    I haven’t tried building from git sources yet. Because I haven’t been able to find a reason for the current event that the point at which the error occurs has changed.
    If I can ignore it, I’ll move on to the second experiment.

I’m not sure about Vendor IDs or Product IDs yet, but list-files.py does work with the error. Doesn’t theta there shoot anything? Or did you just omit the display and it showed up correctly?
Examples of my results

WARNING: gphoto2: (foreach_func [gphoto2-port-info-list.c:237]) Error during assembling of port list: 'Unspecified error' (-1).
WARNING: gphoto2: (gp_port_set_error [gphoto2-port.c:1186]) The supplied vendor or product id (0x0,0x0) is not valid.
File list
=========
/store_00020001/DCIM/100RICOH/R0010132.MP4
/store_00020001/DCIM/100RICOH/R0010133.MP4
/store_00020001/DCIM/100RICOH/R0010134.MP4
/store_00020001/DCIM/100RICOH/R0010135.MP4
/store_00020001/DCIM/100RICOH/R0010136.JPG
/store_00020001/DCIM/100RICOH/R0010137.MP4
/store_00020001/DCIM/100RICOH/R0010138.MP4
...
/store_00020001/DCIM/100RICOH/R0010132.MP4
/store_00020001/DCIM/100RICOH/R0010133.MP4
/store_00020001/DCIM/100RICOH/R0010134.MP4
/store_00020001/DCIM/100RICOH/R0010135.MP4
/store_00020001/DCIM/100RICOH/R0010136.JPG
/store_00020001/DCIM/100RICOH/R0010137.MP4
/store_00020001/DCIM/100RICOH/R0010138.MP4
File info
=========
image dimensions: 1920 960
image type: video/mp4
file mtime: 2020-09-02 19:55:11
1 Like

If you have time, I’d appreciate it if you could reply to me.

Hi, sorry for the delay. I was trying to get more progress before I updated the group here. Unfortunately, I still don’t have libgphoto2 working properly with Python bindings.

Currently, list-files.py does work for me, but I get the same WARNING at the top as you. I would like to eliminate the warning. The output does work, but it is not satisfying.

When I used mhenrie’s program, I have a different error. I get the ‘Unable to copy DNG’ error raised by this section.

        gp_dng_path = wait_for_event(self.camera, timeout=TIMEOUT_CAPTURE_DNG, event_type=gp.GP_EVENT_FILE_ADDED)
        if not gp_dng_path:
            raise RuntimeError('Unable to copy DNG')

Thus, the command line program gphoto2 works for me, but the Python bindings in libgphoto2 do not work.

At the moment, I am using ptpcam from libptp2 inside of programs by running running a shell process inside of my program. As the API commands are not time sensitive, this seems to work, but is not satisfying.

The C functions inside of libptp are not that friendly to use, so I would like to use libghoto2, but I’m not sure if the full library of API commands work with the THETA.

I believe the best path forward is to use mhenrie’s program and modify the _unittest to test less features first, then apply a debugger and see what is happening to the variable dng_path

I just thought that maybe you hadn’t noticed. I’m sorry if I rushed you.

I have been wondering for a long time if it is possible to fix the error at the time of video shooting by modifying the source code of libgPhoto2.
@Hugues has suggested the possibility of resolving the error by modifying the source.
Could it be possible to fix the problem as well, so that gphoto2 --set-config movie=0 does not stop video recording?
I think I can do it.
But I can’t write it because I don’t know what the source code is, but it’s too big for me.
I should be able to figure it out by myself sooner or later.
Is it naive to wait for someone to solve the problem?

Aside from that, I had a similar error when using @mhenrie’s program.
When I saw that error, I took a peek at the shutter speed and exposure time settings that weren’t working properly and made them work.

We have many options.

  • Keep trying the libgPhoto2 system

    • We will continue to use the python-gphoto2 system, which converts C code by SWIG, with analysis and improvement.

    • Use gphoto2-cffi, which is converted by cffi
      I believe operational testing is not yet available on this forum. git, pypi

    • Another use of piggyphoto to convert with another ctype
      ‘This is a very rough proof of concept. feel free to play with it and add improvements.’
      so you might not expect it to work very well. git

  • Try the Python binding in linptp2
    I can’t find anything useful here, according to my research.
    I found a hit on git, but it’s not available on Linux because they don’t know how to compile it as a shared library.
    Does anyone know how to use it?

By the way, I’m going to move on to the next phase of operational testing.

1 Like

I have the same problem with libgphoto2. It is a big project. I have a difficult time understanding it.

I do not think anyone else will solve the problem. It may be up to you if you want the challenge. :slight_smile:

John Thomas was looking at GitHub - Parrot-Developers/sequoia-ptpy: Python library used to communicate with PTP devices like Parrot Sequoia

The last I checked, he did not have it working around 3 weeks ago. Maybe it is working now?

I understand that it is better to have working Python bindings when using ROS on Linux. However, I think that people can run shell process if they need to as a workaround.

In the discussion of that GitHub issue, you may notice a reference to a RICOH USB SDK. Note that SDK is not the SDK for the RICOH THETA. It is for other RICOH cameras.

1 Like

I don’t know if it will be usefull for you but to stop the video recording I’m using the command
gphoto2 --set-config=/main/actions/opcode=0x1018,0xFFFFFFFF

Hugues

2 Likes

I’m surprised there’s such a solution! But unfortunately, it didn’t work in my environment.
My environment is as below.

  • Ubuntu 16.04LTS
  • ThetaV 3.40.1
  • gphoto2 2.5.9
  • libgphoto2 2.5.9
  • libgphoto2_port 0.12.0

※gPhoto2 related items are all unmodified

gphoto2 --set-config=/main/actions/opcode=0x1018,0xFFFFFFFF

*** Error ***
The /main/actions/opcode widget is not configurable.
*** Error (-2: ‘Bad parameters’) ***

For debugging messages, please use the --debug option.
Debugging messages may help finding a solution to your problem.
If you intend to send any error or debug messages to the gphoto
developer mailing list gphoto-devel@lists.sourceforge.net, please run
gphoto2 as follows:

env LANG=C gphoto2 --debug --debug-logfile=my-logfile.txt --set-config=/main/actions/opcode=0x1018,0xFFFFFFFF

Please make sure there is sufficient quoting around the arguments.

First, thanks to @Hugues for providing this fix. Amazing that you could figure it out! I can’t even find the documentation for --set-config=/main/actions/opcode=

Second, for @NaokiSato102, the solution works for me. I believe that maybe you are not starting the video or your THETA is mounted as a file system?

Here is my complete test

unmount camera

If the camera is mounted, the commands may not work.

image

set to video mode

Using the API reference, we can see that video mode is hex 0x8002 or 32770 in base 10.

$ gphoto2 --set-config=5013=32770

start video

$ gphoto2 --set-config movie=1

stop video

$ gphoto2 --set-config=/main/actions/opcode=0x1018,0xFFFFFFFF

start video and stop after specified time

$ gphoto2 --set-config movie=1 --wait-event=2s --set-config movie=0 
Behavior with Audio Beep

There is a beep after each command and no errors on the console.

image

checking media

If you mount the camera again, you can see the media.

image

In my test, I have intentionally disabled internal stitching.

I suspect that your camera may be auto-mounting. Please check it and report back.

I have added this test to the USB API documentation on the Linux streaming documentation I am building. I’m providing attribution to Hugues by linking to his profile on this site along with his ID on this site.

(Missed stringing the replies together.)

I have firmly unmounted Theta and started recording and then tried it.

I would appreciate it if you all could tell me the results of your tests with information on your experimental environment.

Is it interference from other applications etc.? I do not know the reason.
I’m going to try it in the raspberry-pi environment as well.

The fact that the stop command works with --set-config suggests that it can work with the corresponding code in Python-gPhoto2. I can’t think of any code at the moment, but I think I can convert @mhenrie’s code to suit.

Also, was “gphoto2 --set-config movie=1 --wait-event=2s --set-config movie=0” able to exit after the shooting started successfully in @craig’s environment? This should have been inoperative in my perception, i.e. it was not possible to stop shooting.