Re: How to properly set aperture, iso and shutterspeed?

Jochen Keil <[email protected]> Thu, 22 Oct 2020 13:20:57 +0200
Newsgroups gmane.comp.multimedia.gphoto.user
Message-ID <CALrkWEBM+G2rNTfGNNNzWe=93Xkjo1OYPZ1xtpPOptSbumikjw@mail.gmail.com>
Hi Jim,

Thank you for your insightful comments, that's very helpful!

On Tue, Oct 20, 2020 at 5:48 PM Jim Easterbrook <[email protected]>
wrote:

> On 20/10/2020 15:33, Jochen Keil wrote:
> >
> > My idea was to get a list of choices (get_choices()), look up the index
> > of the current value, increase the index by one, look up the new value
> > and set it. This works reasonably well for iso values.
>
> For those not familiar with the Python interface,
> gp_widget_get_choices() and CameraWidget.get_choices() simply call
> gp_widget_get_choice() repeatedly for each possible choice number and
> make a list of the corresponding string values.
>
> > However, there are some oddities when it comes to f-number and
> shutterspeed:
> >
> > For example when the current shutterspeed is above 1/3, `get_value` will
> > return fractions of 10, e.g. 4/10, 10/10, etc. However, the list
> > returned by get_choices contains the value '1' instead of '10/10' hence
> > the lookup fails.
>
> The Python version of gp_widget_get_choice() always returns a string,
> but gp_widget_get_value() returns different types according to the
> widget type:
> GP_WIDGET_MENU, GP_WIDGET_TEXT, GP_WIDGET_RADIO -> string
> GP_WIDGET_RANGE -> float
> GP_WIDGET_DATE, GP_WIDGET_TOGGLE -> integer
>
> I assume you are getting the string '1' rather than the integer 1, in
> which case there appears to be a discrepancy between the C functions
> gp_widget_get_choice() and gp_widget_get_value().
>

Actually, for 'f-number' it's floats only. But for 'shutterspeed' and 'iso'
it's a string (const char *). I've added a full code example below.

> Is there an easy way to set shutterspeed and f-number to the next value
> > or do I have to somehow figure out what 10/10 means and translate it to
> > 1? I think I could use a static table for that but that seems to be
> > laborious and error-prone.
>
> The Python Fraction type is probably the easiest way to convert the
> strings '10/10' and '1' to the same result.
>

So, did I get it right, there is no easy way to step through camera
settings, not even using the native C interface?

Best,

  Jochen



=== Code Example ===

 import gphoto2 as gp

camera = gp.Camera()
camera.init()

config = camera.get_config()

camera.exit()

imgsettings = config.get_child_by_name('imgsettings')
capturesettings = config.get_child_by_name('capturesettings')

iso = imgsettings.get_child_by_name('iso')
fnumber = capturesettings.get_child_by_name('f-number')
shutterspeed = capturesettings.get_child_by_name('shutterspeed')

print(type(iso.get_value()))
print(type(fnumber.get_value()))
print(type(shutterspeed.get_value()))

try:
  iso.set_value('100')
except Exception as e:
  print(e)

try:
  shutterspeed.set_value('10/10')
except Exception as e:
  print(e)

try:
  fnumber.set_value(8)
except Exception as e:
  print(e)

try:
  fnumber.set_value('8')
except Exception as e:
  print(e)

=== Output ===
<class 'str'>
<class 'float'>
<class 'str'>
in method 'CameraWidget_set_value', argument 2 of type 'float'

_______________________________________________
Gphoto-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gphoto-user