Closed gheaeckkseqrz closed 11 months ago
The camera list is reset after you choose a camera. The original script works when I have a Canon DSLR and a phone connected to my computer, your proposed change does not.
We seem to have different behaviours on different computers then. Here is the output from the unmodified script :
➜ /tmp python choose-camera.py
0: usb:001,016 Canon EOS 4000D
1: usb:001,017 Canon EOS 700D
Please input number of chosen camera: 1
WARNING: gphoto2: (gp_libusb1_find_device_by_class_lib [libusb1.c:1465]) Invalid parameters: 'class' is NULL/FALSE.
WARNING: gphoto2: (gp_context_error) An error occurred in the io-library ('Bad parameters'): No error description available
Traceback (most recent call last):
File "/tmp/choose-camera.py", line 91, in <module>
sys.exit(main())
File "/tmp/choose-camera.py", line 76, in main
text = camera.get_summary()
gphoto2.GPhoto2Error: [-2] Bad parameters
And if I add a print as such
# choose camera
camera = gp.Camera()
idx = port_info_list.lookup_path(addr)
camera.set_port_info(port_info_list[idx])
print("camera_list[0][0] ", camera_list[0][0])
idx = abilities_list.lookup_model(camera_list[0][0])
camera.set_abilities(abilities_list[idx])
I get :
➜ /tmp python choose-camera.py
0: usb:001,016 Canon EOS 4000D
1: usb:001,017 Canon EOS 700D
Please input number of chosen camera: 1
camera_list[0][0] Canon EOS 4000D
WARNING: gphoto2: (gp_libusb1_find_device_by_class_lib [libusb1.c:1465]) Invalid parameters: 'class' is NULL/FALSE.
WARNING: gphoto2: (gp_context_error) An error occurred in the io-library ('Bad parameters'): No error description available
Traceback (most recent call last):
File "/tmp/choose-camera.py", line 92, in <module>
sys.exit(main())
File "/tmp/choose-camera.py", line 77, in main
text = camera.get_summary()
gphoto2.GPhoto2Error: [-2] Bad parameters
The script works as expected when selecting camera at index 0, but not at index 1.
What informations do you need in order to investigate this problem?
Extra bit of information that may be relevant, the two cameras are connected on a usb hub, so they may be associated to the same port. This would mean that when running camera_list = abilities_list.detect(port_info_list)
, I get the CameraList *
with two items, whereas someone having two cameras connected to differents usb ports on the motherboard would get only one.
My mistake was to get the name from camera_list
after resetting it - obviously the choice
index is no more likely to be right than 0
. Commit 502e2d3 is how I think I meant to do it, and works for me.
The new version does works on my side too :) Thanks for looking into this, and thanks for developing this library and making it open source :)
I've just done a further rework which I think gets closer to what I was trying to do in the first place.
Tested wih 2 Canon DSLR: 0: usb:001,009 Canon EOS 4000D 1: usb:001,010 Canon EOS 700D