jordens / pyflycapture2

python bindings for the flycapture v2 api (libflycapture-2c)
37 stars 31 forks source link

Setting gain and exposure #14

Closed fonty422 closed 8 years ago

fonty422 commented 8 years ago

I had a good look through flycapture2.pyx and couldn't find any reference to it, but is there a way to set the gain and/or exposure? I'm happy to have a go at writing it myself, but just don't want to reinvent the wheel.

fonty422 commented 8 years ago

Never mind, I have figured it out! As those things are all properties, I just need to set the property by parsing the dictionary full of all the settings I want for the shutter. As an example (to anyone else who struggled with this), I did:

c = fc2.Context()
c.connect(*c.get_camera_from_index(0))

shutter={'on_off': True, 'type': 12, 'value_a': 3L, 'abs_value': 0.13218650817871094, 'one_push': False, 'abs_control': True, 'auto_manual_mode': False, 'present': True, 'value_b': 0L}

print "Current shutter settings: %s\n\n" %c.get_property(fc2.SHUTTER)
c.set_property(**shutter)
print "New shutter settings: %s" %c.get_property(fc2.SHUTTER)
c.disconnect()

and the output:

Current shutter settings: {'on_off': True, 'type': 12, 'value_a': 12L, 'abs_value': 0.12886524200439453, 'one_push': False, 'abs_control': True, 'auto_manual_mode': False, 'present': True, 'value_b': 0L}

New shutter settings: {'on_off': True, 'type': 12, 'value_a': 12L, 'abs_value': 0.12886524200439453, 'one_push': False, 'abs_control': True, 'auto_manual_mode': False, 'present': True, 'value_b': 0L}