Closed n2o closed 11 months ago
Also, I tried your list_files
-Function to see the local files on the camera, but this always returns an empty array.
def list_files(camera, path="/"):
result = []
# get files
for name, value in camera.folder_list_files(path):
result.append(os.path.join(path, name))
# read folders
folders = []
for name, value in camera.folder_list_folders(path):
folders.append(name)
# recurse over subfolders
for name in folders:
result.extend(list_files(camera, os.path.join(path, name)))
return result
Very strange. I have no experience with Sony cameras, but I would expect this to work. Camera.file_delete
isn't expected to return anything - it should raise an exception if gp_camera_file_delete
(which it calls) returns an error. I assume by "nothing happens" you mean the image file remains on the camera SD card.
Check you have libusb1 installed - libusb0 is known to be problematic with some cameras. Other than that I have nothing to suggest.
BTW you can find out what version of libgphoto2 you are using with python -m gphoto2
.
PS Do you set the camera capture target (i.e. SD card or RAM) before calling list_files
? I don't know if it matters or not, but it might be worth checking.
Hi, thanks for the reply. Yes, it simply does not delete the file, I changed the title of this issue :-)
The output of python -m gphoto2
:
python-gphoto2 version: 2.3.4
libgphoto2 version: ['2.5.27', 'standard camlibs', 'gcc', 'ltdl', 'EXIF']
libgphoto2_port version: ['0.12.0', 'iolibs: disk ptpip serial usb1 usbdiskdirect usbscsi', 'gcc', 'ltdl', 'EXIF', 'USB', 'serial without locking']
python-gphoto2 examples: /usr/local/lib/python3.9/dist-packages/gphoto2/examples
I tried the capturetarget
-option, but it seems, that I can't change it 🤔
I have libusb-1.0.24-3 installed.
Still images are stored on the camera 😞
Setting the capture target may only last for the duration of a libgphoto2 session (i.e. until exit()
or the camera is reset). But as it's already set to card+sdram
then it's probably not the problem.
Libgphoto2 2.5.27 isn't ridiculously old (released Feb 2021). The release notes for 2.5.28 include "Sony: mark all widgets as read-write again, read-only logic was not 100% correct" which might explain your capture target setting problem. I can't find anything relevant to deleting pictures though.
Have you tried listing files and deleting files with the gphoto2
command? gphoto2 -v
will show which version of libghoto2 it's using - it isn't necessarily the same as used by python-gphoto2.
Ah, good point. gphoto2 can't even list my files via CLI. Maybe it's just a Sony thing. For my Customer we use Nikon cameras and it works on these cameras. I have no Nikon available currently, which is why I have to work on a Sony camera.
Strange, that this function does not work on a Sony camera.
$ gphoto2 --list-files
There is no file in folder '/'.
$ gphoto2 -v
gphoto2 2.5.27
Copyright (c) 2000-2021 Marcus Meissner and others
gphoto2 comes with NO WARRANTY, to the extent permitted by law. You may
redistribute copies of gphoto2 under the terms of the GNU General Public
License. For more information about these matters, see the files named COPYING.
This version of gphoto2 is using the following software versions and options:
gphoto2 2.5.27 gcc, popt(m), exif, cdk, aa, jpeg, readline
libgphoto2 2.5.27 standard camlibs, gcc, ltdl, EXIF
libgphoto2_port 0.12.0 iolibs: disk ptpip serial usb1 usbdiskdirect usbscsi, gcc, ltdl, EXIF, USB, serial without locking
Actually it seems like a problem with the Sony camera. I tested it on Nikon cameras, which worked as I expected it. Thanks for your help, so I'm closing this and leaving it with "My Sony a6500 simply does not support this" :-)
Just spotted this comment on a libgphoto2 bug report: "For Sony cameras, in pc control mode there is no folder access. It is only accessible in MTP/PTP mode." It might be relevant. https://github.com/gphoto/libgphoto2/issues/798
Your system Raspberry Pi 4
What version of Python are you using? python 3.9.2
What version of libgphoto2 have you installed?
How have you installed (or attempted to install) python-gphoto2? Yes, installed version 2.3.4 via pip
Your problem As far as I can see, there is no possibility to call the function
capture-image-and-download
. So I want to take a picture, download it and delete it afterwards. But when I callfile_delete()
as in your example, nothing happens.That's the relevant function. Taking picture, setting settings etc. works as expected, but the
file_delete()
-function does simply do nothing and return None.I am using a Sony a6500 camera.
I initialize the camera with this code:
Do you have any ideas on this?
Thanks!