alliedvision / VimbaPython

Old Allied Vision Vimba Python API. The successor to this API is VmbPy
BSD 2-Clause "Simplified" License
93 stars 40 forks source link

Example for setting camera gain in python SDK #27

Closed alexsludds closed 3 years ago

alexsludds commented 3 years ago

Hello, I am using the gold eye G008 camera and want to programmatically change the gain setting of the camera in the python SDK. Looking over the documentation it's not obvious to me how to do this. Can an example be added which shows how to change the camera gain? Best, -Alex

NiklasKroeger-AlliedVision commented 3 years ago

Changing the gain setting of the camera is done by accessing the corresponding camera feature and adjusting it's value. There are a few places in our examples, where features are accessed. You can for example see how to get a features name, description, value, etc. in the list_features.py example. Setting of features is for example used in the asynchronous_grab_opencv.py example to turn on the continuous mode for the ExposureAuto feature.

Additionally in section 5.3 of the Vimba Python Manual.pdf there is a small example on how to access and adjust the exposure time feature of a camera.

Adjusting the gain can be done by using the Gain feature of your camera. Adjusting our example would give the following snippet:

with Vimba.get_instance():
    with get_camera(cam_id) as cam:

        # print the current value of the Gain feature
        print(cam.Gain.get())

        # set the value of Gain to three (or whatever you need)
        cam.Gain.set(3)

If you want to access different features from your camera a handy way to figure out their name is to take a look at the feature overview in the VimbaViewer. Here you get a full description of the selected feature, along with the FEATURE NAME. This name is what you need to use to access the feature via VimbaPython. Below is a screenshot of the information displayed for the Gain feature with an Alvium U-500m. image

Thank you for pointing out, that there is no simple example showing feature access provided as runnable .py files. We will consider adding these. In the meantime I will go ahead and close this issue. Feel free to open a new issue if you do have further problems with using VimbaPython.