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

Camera' object has no attribute 'PixelFormat #38

Open sixtemesseven opened 3 years ago

sixtemesseven commented 3 years ago

If I try to read out the pixel format (Mono8) via:

cam.PixelFormat.set("Mono12")

I get an no attribute error. The attribute should be implemented in the camera AV 1800 U-158C (?)

NiklasKroeger-AlliedVision commented 3 years ago

Do you have the camera connection opened in VimbaPython by having entered the with cam: context manager? An AttributeError sounds like the cam object has no attribute named PixelFormat. The camera features are added as attributes to the Camera object when the with: context is entered.

Could you provide a more complete code example with the surrounding lines?

Also the complete error message would be helpful to see if my guess regarding the missing attribute is correct.

sixtemesseven commented 3 years ago
from vimba import *

with Vimba.get_instance () as vimba:
    cams = vimba.get_all_cameras ()
    with cams [0] as cam:       
        cam.Gain.set(24) #Image gain... 0-24 [dB]  #Seems to work    
        cam.PixelFormat.SetValue("Mono12") #Attribute error_

Edit: Code formatting

NiklasKroeger-AlliedVision commented 3 years ago

Ah sorry. I forgot that the PixelFormat feature is somewhat special in Python and it is not added to the object as attribute. To change the pixelformat of your camera special functions are exposed.

This is done because in order to set the pixel format via the camera feature directly, a very precisely formatted string has to be passed which is handed to the VimbaC API. by using the VimbaPython convenience functions you can instead pass an instance of the PixelFormat enum. This is also explained in the VimbaPython manual in section 5.5.

I hope this solves your problem.

nikp00 commented 1 year ago

I came across a similar issue, when trying to run the examples that use Camera.get_pixel_formats, i get this error vimba.error.VimbaFeatureError: Feature 'PixelFormat' not found.. This feture is not listed even while running the Examples/list_features.py.

The camera I'm using:

Teresa-AlliedVision commented 1 year ago

The 1500 C models do not include GenICam over CSI support. Depending on the model, driver and Vimba version you can open the camera in Vimba Viewer and modify the settings, but not stream any frames. I would suggest using V4L2, Gstreamer or direct register access for the 1500s. You can use theV4L2 Viewer on our Github to access some of the camera features. In general, after accessing the camera through V4L2, you need to restart the sysytem, before you can access the camera through our API again. See the release information for the drivers, to see if your version is compatible with GenICam over CSI and if it needs a specific firmware version. A good introduction in how to set up a system for GenICam over CSI can be found on our website. Alvium CSI documentation Getting started with GenICam for CSI - PDF

nikp00 commented 1 year ago

Thank you for the answer, I've missed this in the documentation.