Closed rwijtvliet closed 3 years ago
I don't know enough about libgphoto2's config system to say if making multiple copies of the config tree like this would be expected to work. Are you sure this is a bug in the Python interface? What happens if you do the same operations in a C program?
Thanks for the reply Jim. I am not sure; I unfortunately don't have experience in C or an environment that I could use to check - but I agree it makes sense to check if the behaviour is present on the next level down before trying to fix it on this level.
I did play around with the command line interface but quickly thought it'd be easier to use your python package instead.
Let me know if there's anything I can help with; for the time being I have worked around the issue in the way I mentioned in my post.
I don't know if gp_camera_get_config
constructs a new CameraWidget
tree each time it's called, or if it simply returns a pointer to the same tree. If the latter then what you are trying to do is bound to run into problems. I would try to avoid "copying" the config tree (not least because gp_camera_get_config
takes a long time on some cameras), but keep a pointer to each config item of interest and set their values when required.
Regarding the variables pointing to the same object: that, I tested, is not the case and can also be seen when I print the imagesize
and iso
values which are distinct for each of the configurations cfg0
, cfg1
and cfg2
.
Your solution certainly works; I've gone a bit further and use the distinct configurations (as I had been doing) and a separate set of the settings names that don't have the same value across all. When setting a configuration to the camera, I no longer set it in its entirety, but one setting after the other I get the widget from the configuration in question (with .get_child_by_name
) and set it to the camera (.set_single_config
). That also seem to work and is easier in my use case (where only the changes to the original configuration are specified by each configuration).
I'm glad you've got it working satisfactorily for your purposes.
Closing; found workaround
This page is for reporting problems with the Python interface to libgphoto2. If your question is about using libgphoto2 you should ask on the gphoto2 mailing list.
Your system What version of Python are you using? 3.9
What version of libgphoto2 have you installed? 2.5.25
How have you installed (or attempted to install) python-gphoto2? yes
Your problem I'm trying to assign configurations to variables, so that I can take a series of captures at a later point. The configurations are saved to variables OK, but the setting them with
cam.set_config
seems to not work in all cases.Note especially that
cfg2
hasimagesize
set to6000x4000
. I now take a picture with each configuration:The camera indeed snaps and saves 3 photos, but looking at the final one, its 'imagesize' is not '6000x4000' as specified:
Remarks:
Swapping the order of the configurations also swaps the setting that has a problem. (i.e., it's not a specific problem with the
imagesize
)The second-to-last line, to restore the initial configuration, also does nothing; disconnecting the camera and looking at the LCD shows that it has the settings as used in the final image (i.e, with both the changed image size AND changed iso).
The problem goes away if configurations are set "singly", i.e., if the
cam.set_config()
in the function definition is replaced withbut of course, this isn't practical as it won't in advance be known, which settings are changed between configurations.
Here is the output using the change suggested in the final remark:![image](https://user-images.githubusercontent.com/4106013/111916155-e144f200-8a79-11eb-94ef-4ee88a83c1f0.png)
in the setup.