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

Connecting to Camera without broadcasting on the network #129

Open mmaeusezahl opened 1 year ago

mmaeusezahl commented 1 year ago

Hi,

I'm trying to connect to a camera (Mako) on the same subnet as my PC. This generally works. If I however block broadcast packages (on an intermediate network bridge or router) I can't connect to the camera any longer even if I provide the IP address.

The same happens if I disable network discovery:

Vimba.get_instance().set_network_discovery(False)

In both cases I can see (using WireShark), that the camera and the PC exchange excatly one package successfully and then give up. The same is true for the VimbaViewer. Only if network discovery is enabled and broadcasting packages are allowed I find that everything works fine.

Therefore I'm wondering if network discovery / broadcasting packages are necessary for vimba GigE cameras? If yes, what is the use case of the set_network_discovery function? (In my application I try to avoid allowing broadcast packages in the network)

Example code (click to unfold) ```python from vimba import * from vimba import camera if __name__ == '__main__': cam_id = '192.168.30.12' # I disable network discovery(?) Vimba.get_instance().set_network_discovery(False) with Vimba.get_instance() as vimba: # This seems to never work without broadcasting on the network #cam = vimba.get_camera_by_id(cam_id) # --> vimba.error.VimbaCameraError: No Camera with Id '192.168.30.12' available. # This is a workaround to get a bit further cam = camera.discover_camera(cam_id) print(cam.get_serial()) # works!!!! (this is the one exchanged package) # But if we try to do anything useful with the camera with cam: cam.GainAuto.set('Off') # --> vimba.error.VimbaCameraError: ```

Thanks!

Teresa-AlliedVision commented 1 year ago

Hello Max Mäusezahl, Niklas is on vacation, but I had a look through the python source code regarding set_network_discovery: If 'True' VimbaPython tries to detect cameras connected via Ethernet on entering the 'with' statement. If set to 'False', no network discover occurs. I would assume that if set to false, that no ethernet cameras are searched for. I haven't tried it yet, but the use case for this feature should be to make USB or CSI-2 camera discovery faster (or prioritize them). Unless Niklas has something to add after his vacation I would say that: Yes, you need both. Cheers, Teresa

ivanrajkovic commented 1 year ago

I have a similar problem and would like to be able to connect to the GigE Mako camera by using camera IP address, without network discovery. Is this at all possible with current python API?

Thanks

Teresa-AlliedVision commented 1 year ago

Hello, I checked with the developer: It is not possible. The GVSP discovery packets are necessary for finding the camera(s).

ivanrajkovic commented 1 year ago

How is this done in the VimbaViewer? It has 'Open camera by IP' and it works to open the camera when network discovery is blocked. I know this is done in C but shouldn't it be also possible in python?

Teresa-AlliedVision commented 1 year ago

Hi, thanks for making us aware again, we did check more thoroughly and determined the behaviour to be a bug. You can enter the following lines into the source code of vimba.py under line 292 return cam to solve the issue. The indentation of the new lines should be outside of the for cam in self.__cams: loop, but within the scope of try:. We are working on a fix and if there is a better workaround or he finds a problem with this one, then Niklas will update this issue.

 293                # Camera did not exist in internal camera list. Return newly created camera
 294                return cam_info

The function should look like this then:

        def get_camera_by_id(self, id_: str) -> Camera:
            """Lookup Camera with given ID.

            Arguments:
                id_ - Camera Id to search for. For GigE - Cameras, the IP and MAC-Address
                      can be used to Camera lookup

            Returns:
                Camera associated with given Id.

            Raises:
                TypeError if parameters do not match their type hint.
                RuntimeError then called outside of "with" - statement.
                VimbaCameraError if camera with id_ can't be found.
            """
            with self.__cams_lock:
                # Search for given Camera Id in all currently detected cameras.
                for cam in self.__cams:
                    if id_ == cam.get_id():
                        return cam

                # If a search by ID fails, the given id_ is almost certain an IP or MAC - Address.
                # Try to query this Camera.
                try:
                    cam_info = discover_camera(id_)

                    # Since cam_info is newly constructed, search in existing cameras for a Camera
                    for cam in self.__cams:
                        if cam_info.get_id() == cam.get_id():
                            return cam
                    # Camera did not exist in internal camera list. Return newly created camera
                    return cam_info

                except VimbaCameraError:
                    pass

            raise VimbaCameraError('No Camera with Id \'{}\' available.'.format(id_))
ivanrajkovic commented 1 year ago

Great, thank you for looking into this.

ivanrajkovic commented 1 year ago

Update: I get camera discovered this way, I see results for cam.get_id() and cam.get_id() but nothing else really works. It only works if I use

cam = get_camera(ip)

as soon as I try to use with statement, it fails.

running this code:

with Vimba.get_instance():
    with get_camera(ip) as cam:
        print('Print all features of camera \'{}\':'.format(cam.get_id()))
        for feature in cam.get_all_features():
            print_feature(feature)

fails with a lot of errors:

Traceback (most recent call last):
  File "C:\Users\rajkovic\Documents\programs-git\mako\Vimba6\tests.py", line 70, in <module>
    with get_camera(ip) as cam:
  File "c:\users\rajkovic\mambaforge\lib\site-packages\vimba\util\tracer.py", line 134, in wrapper
    return func(*args, **kwargs)
  File "c:\users\rajkovic\mambaforge\lib\site-packages\vimba\camera.py", line 362, in __enter__
    self._open()
  File "c:\users\rajkovic\mambaforge\lib\site-packages\vimba\util\tracer.py", line 134, in wrapper
    return func(*args, **kwargs)
  File "c:\users\rajkovic\mambaforge\lib\site-packages\vimba\util\context_decorator.py", line 44, in wrapper
    return func(*args, **kwargs)
  File "c:\users\rajkovic\mambaforge\lib\site-packages\vimba\camera.py", line 924, in _open
    raise exc from e
vimba.error.VimbaCameraError: <VmbError.NotFound: -3>
Teresa-AlliedVision commented 1 year ago

Hi, I assume you're using Vimba6 and have already modified the source code of vimba.py to work around the network discovery bug? Try the following minimal example, if it doesn't work, enable the trace log and post the trace for troubleshooting please. My PoE switch has broadcast packages enabled, so I disable network discovery through vmb.set_network_discovery(False).

from vimba import *

def print_preamble():
    print('///////////////////////////////////////////')
    print('/// Vimba Python No Broadcast Discovery ///')
    print('///////////////////////////////////////////\n')

def print_camera(cam: Camera):
    print('/// Camera Name   : {}'.format(cam.get_name()))
    print('/// Model Name    : {}'.format(cam.get_model()))
    print('/// Camera ID     : {}'.format(cam.get_id()))
    print('/// Serial Number : {}'.format(cam.get_serial()))
    print('/// Interface ID  : {}\n'.format(cam.get_interface_id()))

def main():
    print_preamble()
    vmb = Vimba.get_instance()
    #comment out if trace log is needed:
    #vmb.enable_log(LOG_CONFIG_TRACE_FILE_ONLY)
    vmb.set_network_discovery(False)
    with vmb:
        cameras = vmb.get_all_cameras()
        if not cameras:
            print("/// Camera list from broadcast discovery is empty.\n")

        cam = vmb.get_camera_by_id("123.123.123.123") #Put IP-address here as string
        if cam:
            print("/// Camera was found through IP-address:")
            print_camera(cam)
            with cam:
                print(cam.get_frame()) #Check if the camera can be opened and if it streams one frame

if __name__ == '__main__':
    main()
ivanrajkovic commented 1 year ago

Yes, I am using Vimba 6 and I've altered the code as specified in this thread. Some more info about my setup: win10, network discovery blocked by company policy (Control Panel\All Control Panel Items\Network and Sharing Center\Advanced sharing settings) python 3.9.13 camera -> POE injector -> usb network adapter -> computer

It still doesn't work, here is the tracelog:

2023-02-09 10:08:15,633 | Trace    | Enter | vimba.vimba.Vimba.__Impl.__enter__(self)
2023-02-09 10:08:15,633 | Trace    | Enter |   vimba.vimba.Vimba.__Impl._startup(self)
2023-02-09 10:08:15,633 | Info     | Starting VimbaPython: 1.2.1 (using VimbaC: 1.9.1, VimbaImageTransform: 1.6)
2023-02-09 10:08:15,633 | Trace    | Enter |     vimba.c_binding.vimba_c.call_vimba_c(VmbStartup, ())
2023-02-09 10:08:15,683 | Trace    | Leave |     vimba.c_binding.vimba_c.call_vimba_c
2023-02-09 10:08:15,683 | Trace    | Enter |     vimba.interface.discover_interfaces(None)
2023-02-09 10:08:15,695 | Trace    | Enter |       vimba.c_binding.vimba_c.call_vimba_c(VmbInterfacesList, (None, 0, <cparam 'P' (0x000001AA89A6F688)>, 40))
2023-02-09 10:08:15,695 | Trace    | Leave |       vimba.c_binding.vimba_c.call_vimba_c
2023-02-09 10:08:15,695 | Trace    | Enter |       vimba.c_binding.vimba_c.call_vimba_c(VmbInterfacesList, (<vimba.interface.VmbInterfaceInfo_Array_3 object at 0x000001AA890E47C0>, c_ulong(3), <cparam 'P' (0x000001AA890E4B ...
2023-02-09 10:08:15,695 | Trace    | Leave |       vimba.c_binding.vimba_c.call_vimba_c
2023-02-09 10:08:15,695 | Trace    | Enter |       vimba.interface.Interface.__init__(self, VmbInterfaceInfo(interfaceIdString=b'VimbaUSBInterface_0x0',interfaceType=<VmbInterface.Usb: 3>,interfaceName=b'Vimba USB Interfac ...
2023-02-09 10:08:15,695 | Trace    | Leave |       vimba.interface.Interface.__init__
2023-02-09 10:08:15,695 | Trace    | Enter |       vimba.interface.Interface.__init__(self, VmbInterfaceInfo(interfaceIdString=b'Local Area Connection',interfaceType=<VmbInterface.Ethernet: 2>,interfaceName=b'Local Area Co ...
2023-02-09 10:08:15,695 | Trace    | Leave |       vimba.interface.Interface.__init__
2023-02-09 10:08:15,695 | Trace    | Enter |       vimba.interface.Interface.__init__(self, VmbInterfaceInfo(interfaceIdString=b'Ethernet 2',interfaceType=<VmbInterface.Ethernet: 2>,interfaceName=b'Ethernet 2',serialString ...
2023-02-09 10:08:15,695 | Trace    | Leave |       vimba.interface.Interface.__init__
2023-02-09 10:08:15,695 | Trace    | Leave |     vimba.interface.discover_interfaces
2023-02-09 10:08:15,695 | Trace    | Enter |     vimba.camera.discover_cameras(False)
2023-02-09 10:08:15,695 | Trace    | Enter |       vimba.c_binding.vimba_c.call_vimba_c(VmbCamerasList, (None, 0, <cparam 'P' (0x000001AA890E4B08)>, 0))
2023-02-09 10:08:15,695 | Trace    | Leave |       vimba.c_binding.vimba_c.call_vimba_c
2023-02-09 10:08:15,695 | Trace    | Leave |     vimba.camera.discover_cameras
2023-02-09 10:08:15,695 | Trace    | Enter |     vimba.feature.discover_features(c_void_p(1))
2023-02-09 10:08:15,695 | Trace    | Enter |       vimba.c_binding.vimba_c.call_vimba_c(VmbFeaturesList, (c_void_p(1), None, 0, <cparam 'P' (0x000001AA890E4B08)>, 96))
2023-02-09 10:08:15,695 | Trace    | Leave |       vimba.c_binding.vimba_c.call_vimba_c
2023-02-09 10:08:15,695 | Trace    | Enter |       vimba.c_binding.vimba_c.call_vimba_c(VmbFeaturesList, (c_void_p(1), <vimba.feature.VmbFeatureInfo_Array_24 object at 0x000001AA89B42DC0>, c_ulong(24), <cparam 'P' (0x00000 ...
2023-02-09 10:08:15,695 | Trace    | Leave |       vimba.c_binding.vimba_c.call_vimba_c
2023-02-09 10:08:15,695 | Trace    | Enter |       vimba.feature.CommandFeature.__init__(self, c_void_p(1), VmbFeatureInfo(name=b'ActionCommand',featureDataType=<VmbFeatureData.Command: 6>,featureFlags= <VmbFeatureFlags.Re ...
2023-02-09 10:08:15,695 | Trace    | Leave |       vimba.feature.CommandFeature.__init__
2023-02-09 10:08:15,695 | Trace    | Enter |       vimba.feature.IntFeature.__init__(self, c_void_p(1), VmbFeatureInfo(name=b'ActionDeviceKey',featureDataType=<VmbFeatureData.Int: 1>,featureFlags= <VmbFeatureFlags.Read: 1> ...
2023-02-09 10:08:15,695 | Trace    | Leave |       vimba.feature.IntFeature.__init__
2023-02-09 10:08:15,695 | Trace    | Enter |       vimba.feature.IntFeature.__init__(self, c_void_p(1), VmbFeatureInfo(name=b'ActionGroupKey',featureDataType=<VmbFeatureData.Int: 1>,featureFlags= <VmbFeatureFlags.Read: 1>  ...
2023-02-09 10:08:15,695 | Trace    | Leave |       vimba.feature.IntFeature.__init__
2023-02-09 10:08:15,695 | Trace    | Enter |       vimba.feature.IntFeature.__init__(self, c_void_p(1), VmbFeatureInfo(name=b'ActionGroupMask',featureDataType=<VmbFeatureData.Int: 1>,featureFlags= <VmbFeatureFlags.Read: 1> ...
2023-02-09 10:08:15,695 | Trace    | Leave |       vimba.feature.IntFeature.__init__
2023-02-09 10:08:15,695 | Trace    | Enter |       vimba.feature.BoolFeature.__init__(self, c_void_p(1), VmbFeatureInfo(name=b'CLTLIsPresent',featureDataType=<VmbFeatureData.Bool: 5>,featureFlags= <VmbFeatureFlags.Read: 1> ...
2023-02-09 10:08:15,695 | Trace    | Leave |       vimba.feature.BoolFeature.__init__
2023-02-09 10:08:15,695 | Trace    | Enter |       vimba.feature.EnumFeature.__init__(self, c_void_p(1), VmbFeatureInfo(name=b'DiscoveryCameraEvent',featureDataType=<VmbFeatureData.Enum: 3>,featureFlags= <VmbFeatureFlags.R ...
2023-02-09 10:08:15,695 | Trace    | Enter |         vimba.feature._discover_enum_entries(c_void_p(1), b'DiscoveryCameraEvent')
2023-02-09 10:08:15,695 | Trace    | Enter |           vimba.c_binding.vimba_c.call_vimba_c(VmbFeatureEnumRangeQuery, (c_void_p(1), b'DiscoveryCameraEvent', None, 0, <cparam 'P' (0x000001AA89B85788)>))
2023-02-09 10:08:15,695 | Trace    | Leave |           vimba.c_binding.vimba_c.call_vimba_c
2023-02-09 10:08:15,695 | Trace    | Enter |           vimba.c_binding.vimba_c.call_vimba_c(VmbFeatureEnumRangeQuery, (c_void_p(1), b'DiscoveryCameraEvent', <vimba.feature.c_char_p_Array_4 object at 0x000001AA89B85840>, c_ ...
2023-02-09 10:08:15,695 | Trace    | Leave |           vimba.c_binding.vimba_c.call_vimba_c
2023-02-09 10:08:15,695 | Trace    | Enter |           vimba.c_binding.vimba_c.call_vimba_c(VmbFeatureEnumEntryGet, (c_void_p(1), b'DiscoveryCameraEvent', b'Missing', <cparam 'P' (0x000001AA89B7DE70)>, 56))
2023-02-09 10:08:15,695 | Trace    | Leave |           vimba.c_binding.vimba_c.call_vimba_c
2023-02-09 10:08:15,695 | Trace    | Enter |           vimba.feature.EnumEntry.__init__(self, c_void_p(1), b'DiscoveryCameraEvent', VmbFeatureEnumEntry(name=b'Missing',displayName=b'Missing',visibility=<VmbFeatureVisibilit ...
2023-02-09 10:08:15,695 | Trace    | Leave |           vimba.feature.EnumEntry.__init__
2023-02-09 10:08:15,695 | Trace    | Enter |           vimba.c_binding.vimba_c.call_vimba_c(VmbFeatureEnumEntryGet, (c_void_p(1), b'DiscoveryCameraEvent', b'Detected', <cparam 'P' (0x000001AA89B7DDF0)>, 56))
2023-02-09 10:08:15,695 | Trace    | Leave |           vimba.c_binding.vimba_c.call_vimba_c
2023-02-09 10:08:15,695 | Trace    | Enter |           vimba.feature.EnumEntry.__init__(self, c_void_p(1), b'DiscoveryCameraEvent', VmbFeatureEnumEntry(name=b'Detected',displayName=b'Detected',visibility=<VmbFeatureVisibil ...
2023-02-09 10:08:15,695 | Trace    | Leave |           vimba.feature.EnumEntry.__init__
2023-02-09 10:08:15,695 | Trace    | Enter |           vimba.c_binding.vimba_c.call_vimba_c(VmbFeatureEnumEntryGet, (c_void_p(1), b'DiscoveryCameraEvent', b'Reachable', <cparam 'P' (0x000001AA89B87170)>, 56))
2023-02-09 10:08:15,695 | Trace    | Leave |           vimba.c_binding.vimba_c.call_vimba_c
2023-02-09 10:08:15,695 | Trace    | Enter |           vimba.feature.EnumEntry.__init__(self, c_void_p(1), b'DiscoveryCameraEvent', VmbFeatureEnumEntry(name=b'Reachable',displayName=b'Reachable',visibility=<VmbFeatureVisib ...
2023-02-09 10:08:15,695 | Trace    | Leave |           vimba.feature.EnumEntry.__init__
2023-02-09 10:08:15,695 | Trace    | Enter |           vimba.c_binding.vimba_c.call_vimba_c(VmbFeatureEnumEntryGet, (c_void_p(1), b'DiscoveryCameraEvent', b'Unreachable', <cparam 'P' (0x000001AA89B87230)>, 56))
2023-02-09 10:08:15,695 | Trace    | Leave |           vimba.c_binding.vimba_c.call_vimba_c
2023-02-09 10:08:15,695 | Trace    | Enter |           vimba.feature.EnumEntry.__init__(self, c_void_p(1), b'DiscoveryCameraEvent', VmbFeatureEnumEntry(name=b'Unreachable',displayName=b'Unreachable',visibility=<VmbFeatureV ...
2023-02-09 10:08:15,695 | Trace    | Leave |           vimba.feature.EnumEntry.__init__
2023-02-09 10:08:15,695 | Trace    | Leave |         vimba.feature._discover_enum_entries
2023-02-09 10:08:15,695 | Trace    | Leave |       vimba.feature.EnumFeature.__init__
2023-02-09 10:08:15,695 | Trace    | Enter |       vimba.feature.StringFeature.__init__(self, c_void_p(1), VmbFeatureInfo(name=b'DiscoveryCameraIdent',featureDataType=<VmbFeatureData.String: 4>,featureFlags= <VmbFeatureFla ...
2023-02-09 10:08:15,695 | Trace    | Leave |       vimba.feature.StringFeature.__init__
2023-02-09 10:08:15,695 | Trace    | Enter |       vimba.feature.EnumFeature.__init__(self, c_void_p(1), VmbFeatureInfo(name=b'DiscoveryInterfaceEvent',featureDataType=<VmbFeatureData.Enum: 3>,featureFlags= <VmbFeatureFlag ...
2023-02-09 10:08:15,695 | Trace    | Enter |         vimba.feature._discover_enum_entries(c_void_p(1), b'DiscoveryInterfaceEvent')
2023-02-09 10:08:15,695 | Trace    | Enter |           vimba.c_binding.vimba_c.call_vimba_c(VmbFeatureEnumRangeQuery, (c_void_p(1), b'DiscoveryInterfaceEvent', None, 0, <cparam 'P' (0x000001AA89B85888)>))
2023-02-09 10:08:15,695 | Trace    | Leave |           vimba.c_binding.vimba_c.call_vimba_c
2023-02-09 10:08:15,695 | Trace    | Enter |           vimba.c_binding.vimba_c.call_vimba_c(VmbFeatureEnumRangeQuery, (c_void_p(1), b'DiscoveryInterfaceEvent', <vimba.feature.c_char_p_Array_2 object at 0x000001AA89B85740>, ...
2023-02-09 10:08:15,695 | Trace    | Leave |           vimba.c_binding.vimba_c.call_vimba_c
2023-02-09 10:08:15,695 | Trace    | Enter |           vimba.c_binding.vimba_c.call_vimba_c(VmbFeatureEnumEntryGet, (c_void_p(1), b'DiscoveryInterfaceEvent', b'Unavailable', <cparam 'P' (0x000001AA89B87530)>, 56))
2023-02-09 10:08:15,695 | Trace    | Leave |           vimba.c_binding.vimba_c.call_vimba_c
2023-02-09 10:08:15,695 | Trace    | Enter |           vimba.feature.EnumEntry.__init__(self, c_void_p(1), b'DiscoveryInterfaceEvent', VmbFeatureEnumEntry(name=b'Unavailable',displayName=b'Unavailable',visibility=<VmbFeatu ...
2023-02-09 10:08:15,695 | Trace    | Leave |           vimba.feature.EnumEntry.__init__
2023-02-09 10:08:15,695 | Trace    | Enter |           vimba.c_binding.vimba_c.call_vimba_c(VmbFeatureEnumEntryGet, (c_void_p(1), b'DiscoveryInterfaceEvent', b'Available', <cparam 'P' (0x000001AA89B876F0)>, 56))
2023-02-09 10:08:15,695 | Trace    | Leave |           vimba.c_binding.vimba_c.call_vimba_c
2023-02-09 10:08:15,695 | Trace    | Enter |           vimba.feature.EnumEntry.__init__(self, c_void_p(1), b'DiscoveryInterfaceEvent', VmbFeatureEnumEntry(name=b'Available',displayName=b'Available',visibility=<VmbFeatureVi ...
2023-02-09 10:08:15,695 | Trace    | Leave |           vimba.feature.EnumEntry.__init__
2023-02-09 10:08:15,695 | Trace    | Leave |         vimba.feature._discover_enum_entries
2023-02-09 10:08:15,695 | Trace    | Leave |       vimba.feature.EnumFeature.__init__
2023-02-09 10:08:15,695 | Trace    | Enter |       vimba.feature.StringFeature.__init__(self, c_void_p(1), VmbFeatureInfo(name=b'DiscoveryInterfaceIdent',featureDataType=<VmbFeatureData.String: 4>,featureFlags= <VmbFeature ...
2023-02-09 10:08:15,710 | Trace    | Leave |       vimba.feature.StringFeature.__init__
2023-02-09 10:08:15,710 | Trace    | Enter |       vimba.feature.FloatFeature.__init__(self, c_void_p(1), VmbFeatureInfo(name=b'Elapsed',featureDataType=<VmbFeatureData.Float: 2>,featureFlags= <VmbFeatureFlags.Read: 1> <Vm ...
2023-02-09 10:08:15,710 | Trace    | Leave |       vimba.feature.FloatFeature.__init__
2023-02-09 10:08:15,710 | Trace    | Enter |       vimba.feature.BoolFeature.__init__(self, c_void_p(1), VmbFeatureInfo(name=b'FiWTLIsPresent',featureDataType=<VmbFeatureData.Bool: 5>,featureFlags= <VmbFeatureFlags.Read: 1 ...
2023-02-09 10:08:15,710 | Trace    | Leave |       vimba.feature.BoolFeature.__init__
2023-02-09 10:08:15,710 | Trace    | Enter |       vimba.feature.CommandFeature.__init__(self, c_void_p(1), VmbFeatureInfo(name=b'GeVDiscoveryAllAuto',featureDataType=<VmbFeatureData.Command: 6>,featureFlags= <VmbFeatureFl ...
2023-02-09 10:08:15,710 | Trace    | Leave |       vimba.feature.CommandFeature.__init__
2023-02-09 10:08:15,710 | Trace    | Enter |       vimba.feature.IntFeature.__init__(self, c_void_p(1), VmbFeatureInfo(name=b'GeVDiscoveryAllDuration',featureDataType=<VmbFeatureData.Int: 1>,featureFlags= <VmbFeatureFlags. ...
2023-02-09 10:08:15,710 | Trace    | Leave |       vimba.feature.IntFeature.__init__
2023-02-09 10:08:15,710 | Trace    | Enter |       vimba.feature.CommandFeature.__init__(self, c_void_p(1), VmbFeatureInfo(name=b'GeVDiscoveryAllOff',featureDataType=<VmbFeatureData.Command: 6>,featureFlags= <VmbFeatureFla ...
2023-02-09 10:08:15,710 | Trace    | Leave |       vimba.feature.CommandFeature.__init__
2023-02-09 10:08:15,710 | Trace    | Enter |       vimba.feature.CommandFeature.__init__(self, c_void_p(1), VmbFeatureInfo(name=b'GeVDiscoveryAllOnce',featureDataType=<VmbFeatureData.Command: 6>,featureFlags= <VmbFeatureFl ...
2023-02-09 10:08:15,710 | Trace    | Leave |       vimba.feature.CommandFeature.__init__
2023-02-09 10:08:15,710 | Trace    | Enter |       vimba.feature.EnumFeature.__init__(self, c_void_p(1), VmbFeatureInfo(name=b'GeVDiscoveryStatus',featureDataType=<VmbFeatureData.Enum: 3>,featureFlags= <VmbFeatureFlags.Rea ...
2023-02-09 10:08:15,710 | Trace    | Enter |         vimba.feature._discover_enum_entries(c_void_p(1), b'GeVDiscoveryStatus')
2023-02-09 10:08:15,710 | Trace    | Enter |           vimba.c_binding.vimba_c.call_vimba_c(VmbFeatureEnumRangeQuery, (c_void_p(1), b'GeVDiscoveryStatus', None, 0, <cparam 'P' (0x000001AA89B85808)>))
2023-02-09 10:08:15,710 | Trace    | Leave |           vimba.c_binding.vimba_c.call_vimba_c
2023-02-09 10:08:15,710 | Trace    | Enter |           vimba.c_binding.vimba_c.call_vimba_c(VmbFeatureEnumRangeQuery, (c_void_p(1), b'GeVDiscoveryStatus', <vimba.feature.c_char_p_Array_3 object at 0x000001AA89B85840>, c_ul ...
2023-02-09 10:08:15,710 | Trace    | Leave |           vimba.c_binding.vimba_c.call_vimba_c
2023-02-09 10:08:15,710 | Trace    | Enter |           vimba.c_binding.vimba_c.call_vimba_c(VmbFeatureEnumEntryGet, (c_void_p(1), b'GeVDiscoveryStatus', b'AllOff', <cparam 'P' (0x000001AA89B87C70)>, 56))
2023-02-09 10:08:15,710 | Trace    | Leave |           vimba.c_binding.vimba_c.call_vimba_c
2023-02-09 10:08:15,710 | Trace    | Enter |           vimba.feature.EnumEntry.__init__(self, c_void_p(1), b'GeVDiscoveryStatus', VmbFeatureEnumEntry(name=b'AllOff',displayName=b'AllOff',visibility=<VmbFeatureVisibility.Be ...
2023-02-09 10:08:15,710 | Trace    | Leave |           vimba.feature.EnumEntry.__init__
2023-02-09 10:08:15,710 | Trace    | Enter |           vimba.c_binding.vimba_c.call_vimba_c(VmbFeatureEnumEntryGet, (c_void_p(1), b'GeVDiscoveryStatus', b'AllAuto', <cparam 'P' (0x000001AA89B87DB0)>, 56))
2023-02-09 10:08:15,710 | Trace    | Leave |           vimba.c_binding.vimba_c.call_vimba_c
2023-02-09 10:08:15,710 | Trace    | Enter |           vimba.feature.EnumEntry.__init__(self, c_void_p(1), b'GeVDiscoveryStatus', VmbFeatureEnumEntry(name=b'AllAuto',displayName=b'AllAuto',visibility=<VmbFeatureVisibility. ...
2023-02-09 10:08:15,710 | Trace    | Leave |           vimba.feature.EnumEntry.__init__
2023-02-09 10:08:15,710 | Trace    | Enter |           vimba.c_binding.vimba_c.call_vimba_c(VmbFeatureEnumEntryGet, (c_void_p(1), b'GeVDiscoveryStatus', b'AllOnce', <cparam 'P' (0x000001AA89B87F30)>, 56))
2023-02-09 10:08:15,710 | Trace    | Leave |           vimba.c_binding.vimba_c.call_vimba_c
2023-02-09 10:08:15,710 | Trace    | Enter |           vimba.feature.EnumEntry.__init__(self, c_void_p(1), b'GeVDiscoveryStatus', VmbFeatureEnumEntry(name=b'AllOnce',displayName=b'AllOnce',visibility=<VmbFeatureVisibility. ...
2023-02-09 10:08:15,710 | Trace    | Leave |           vimba.feature.EnumEntry.__init__
2023-02-09 10:08:15,710 | Trace    | Leave |         vimba.feature._discover_enum_entries
2023-02-09 10:08:15,710 | Trace    | Leave |       vimba.feature.EnumFeature.__init__
2023-02-09 10:08:15,710 | Trace    | Enter |       vimba.feature.BoolFeature.__init__(self, c_void_p(1), VmbFeatureInfo(name=b'GeVTLIsPresent',featureDataType=<VmbFeatureData.Bool: 5>,featureFlags= <VmbFeatureFlags.Read: 1 ...
2023-02-09 10:08:15,710 | Trace    | Leave |       vimba.feature.BoolFeature.__init__
2023-02-09 10:08:15,710 | Trace    | Enter |       vimba.feature.IntFeature.__init__(self, c_void_p(1), VmbFeatureInfo(name=b'GevActionDestinationIPAddress',featureDataType=<VmbFeatureData.Int: 1>,featureFlags= <VmbFeature ...
2023-02-09 10:08:15,710 | Trace    | Leave |       vimba.feature.IntFeature.__init__
2023-02-09 10:08:15,710 | Trace    | Enter |       vimba.feature.IntFeature.__init__(self, c_void_p(1), VmbFeatureInfo(name=b'GevDeviceForceGateway',featureDataType=<VmbFeatureData.Int: 1>,featureFlags= <VmbFeatureFlags.Re ...
2023-02-09 10:08:15,710 | Trace    | Leave |       vimba.feature.IntFeature.__init__
2023-02-09 10:08:15,710 | Trace    | Enter |       vimba.feature.CommandFeature.__init__(self, c_void_p(1), VmbFeatureInfo(name=b'GevDeviceForceIP',featureDataType=<VmbFeatureData.Command: 6>,featureFlags= <VmbFeatureFlags ...
2023-02-09 10:08:15,710 | Trace    | Leave |       vimba.feature.CommandFeature.__init__
2023-02-09 10:08:15,710 | Trace    | Enter |       vimba.feature.IntFeature.__init__(self, c_void_p(1), VmbFeatureInfo(name=b'GevDeviceForceIPAddress',featureDataType=<VmbFeatureData.Int: 1>,featureFlags= <VmbFeatureFlags. ...
2023-02-09 10:08:15,710 | Trace    | Leave |       vimba.feature.IntFeature.__init__
2023-02-09 10:08:15,710 | Trace    | Enter |       vimba.feature.IntFeature.__init__(self, c_void_p(1), VmbFeatureInfo(name=b'GevDeviceForceMACAddress',featureDataType=<VmbFeatureData.Int: 1>,featureFlags= <VmbFeatureFlags ...
2023-02-09 10:08:15,710 | Trace    | Leave |       vimba.feature.IntFeature.__init__
2023-02-09 10:08:15,710 | Trace    | Enter |       vimba.feature.IntFeature.__init__(self, c_void_p(1), VmbFeatureInfo(name=b'GevDeviceForceSubnetMask',featureDataType=<VmbFeatureData.Int: 1>,featureFlags= <VmbFeatureFlags ...
2023-02-09 10:08:15,710 | Trace    | Leave |       vimba.feature.IntFeature.__init__
2023-02-09 10:08:15,710 | Trace    | Enter |       vimba.feature.BoolFeature.__init__(self, c_void_p(1), VmbFeatureInfo(name=b'UsbTLIsPresent',featureDataType=<VmbFeatureData.Bool: 5>,featureFlags= <VmbFeatureFlags.Read: 1 ...
2023-02-09 10:08:15,710 | Trace    | Leave |       vimba.feature.BoolFeature.__init__
2023-02-09 10:08:15,710 | Trace    | Leave |     vimba.feature.discover_features
2023-02-09 10:08:15,710 | Trace    | Enter |     vimba.shared.attach_feature_accessors(<vimba.vimba.Vimba.__Impl object at 0x000001AA89B782E0>, (Feature(_handle=c_void_p(1),_info=VmbFeatureInfo(name=b'ActionCommand',featur ...
2023-02-09 10:08:15,710 | Trace    | Leave |     vimba.shared.attach_feature_accessors
2023-02-09 10:08:15,710 | Trace    | Enter |     vimba.shared.filter_features_by_name((Feature(_handle=c_void_p(1),_info=VmbFeatureInfo(name=b'ActionCommand',featureDataType=<VmbFeatureData.Command: 6>,featureFlags= <VmbFe ...
2023-02-09 10:08:15,710 | Trace    | Leave |     vimba.shared.filter_features_by_name
2023-02-09 10:08:15,710 | Trace    | Enter |     vimba.feature._BaseFeature.__register_callback(self)
2023-02-09 10:08:15,710 | Trace    | Enter |       vimba.c_binding.vimba_c.call_vimba_c(VmbFeatureInvalidationRegister, (c_void_p(1), b'DiscoveryInterfaceEvent', <CFunctionType object at 0x000001AA89B862B0>, None))
2023-02-09 10:08:15,710 | Trace    | Leave |       vimba.c_binding.vimba_c.call_vimba_c
2023-02-09 10:08:15,710 | Trace    | Leave |     vimba.feature._BaseFeature.__register_callback
2023-02-09 10:08:15,710 | Trace    | Enter |     vimba.shared.filter_features_by_name((Feature(_handle=c_void_p(1),_info=VmbFeatureInfo(name=b'ActionCommand',featureDataType=<VmbFeatureData.Command: 6>,featureFlags= <VmbFe ...
2023-02-09 10:08:15,710 | Trace    | Leave |     vimba.shared.filter_features_by_name
2023-02-09 10:08:15,710 | Trace    | Enter |     vimba.feature._BaseFeature.__register_callback(self)
2023-02-09 10:08:15,710 | Trace    | Enter |       vimba.c_binding.vimba_c.call_vimba_c(VmbFeatureInvalidationRegister, (c_void_p(1), b'DiscoveryCameraEvent', <CFunctionType object at 0x000001AA89B86040>, None))
2023-02-09 10:08:15,710 | Trace    | Leave |       vimba.c_binding.vimba_c.call_vimba_c
2023-02-09 10:08:15,710 | Trace    | Leave |     vimba.feature._BaseFeature.__register_callback
2023-02-09 10:08:15,710 | Trace    | Leave |   vimba.vimba.Vimba.__Impl._startup
2023-02-09 10:08:15,710 | Trace    | Leave | vimba.vimba.Vimba.__Impl.__enter__
2023-02-09 10:08:15,710 | Trace    | Enter | vimba.camera.discover_camera(169.254.234.12)
2023-02-09 10:08:15,710 | Trace    | Enter |   vimba.c_binding.vimba_c.call_vimba_c(VmbCameraInfoQuery, (b'169.254.234.12', <cparam 'P' (0x000001AA87457180)>, 48))
2023-02-09 10:08:18,952 | Trace    | Leave |   vimba.c_binding.vimba_c.call_vimba_c
2023-02-09 10:08:18,952 | Trace    | Enter |   vimba.camera.Camera.__init__(self, VmbCameraInfo(cameraIdString=b'DEV_000F315C28CA',cameraName=b'Mako',modelName=b'Mako G-030B (5044)',serialString=b'50-0536910922',permittedA ...
2023-02-09 10:08:18,952 | Trace    | Leave |   vimba.camera.Camera.__init__
2023-02-09 10:08:18,952 | Trace    | Leave | vimba.camera.discover_camera
2023-02-09 10:08:18,959 | Trace    | Enter | vimba.camera.Camera.__enter__(self)
2023-02-09 10:08:18,959 | Trace    | Enter |   vimba.camera.Camera._open(self)
2023-02-09 10:08:18,959 | Trace    | Enter |     vimba.c_binding.vimba_c.call_vimba_c(VmbCameraOpen, (b'DEV_000F315C28CA', <AccessMode.Full: 1>, <cparam 'P' (0x000001AA890E4108)>))
2023-02-09 10:08:22,081 | Trace    | Raise |     vimba.c_binding.vimba_c.call_vimba_c, ErrorType: <class 'vimba.c_binding.vimba_common.VimbaCError'>, ErrorValue: VimbaCError(<VmbError.NotFound: -3>)
2023-02-09 10:08:22,081 | Error    | <VmbError.NotFound: -3>
2023-02-09 10:08:22,081 | Trace    | Raise |   vimba.camera.Camera._open, ErrorType: <class 'vimba.error.VimbaCameraError'>, ErrorValue: <VmbError.NotFound: -3>
2023-02-09 10:08:22,081 | Trace    | Raise | vimba.camera.Camera.__enter__, ErrorType: <class 'vimba.error.VimbaCameraError'>, ErrorValue: <VmbError.NotFound: -3>
2023-02-09 10:08:22,081 | Trace    | Enter | vimba.vimba.Vimba.__Impl.__exit__(self, <class 'vimba.error.VimbaCameraError'>, <VmbError.NotFound: -3>, <traceback object at 0x000001AA89B7D180>)
2023-02-09 10:08:22,081 | Trace    | Enter |   vimba.vimba.Vimba.__Impl._shutdown(self)
2023-02-09 10:08:22,081 | Trace    | Enter |     vimba.feature._BaseFeature.__unregister_callback(self)
2023-02-09 10:08:22,081 | Trace    | Enter |       vimba.c_binding.vimba_c.call_vimba_c(VmbFeatureInvalidationUnregister, (c_void_p(1), b'DiscoveryCameraEvent', <CFunctionType object at 0x000001AA89B86040>))
2023-02-09 10:08:22,081 | Trace    | Leave |       vimba.c_binding.vimba_c.call_vimba_c
2023-02-09 10:08:22,081 | Trace    | Leave |     vimba.feature._BaseFeature.__unregister_callback
2023-02-09 10:08:22,081 | Trace    | Enter |     vimba.feature._BaseFeature.__unregister_callback(self)
2023-02-09 10:08:22,081 | Trace    | Enter |       vimba.c_binding.vimba_c.call_vimba_c(VmbFeatureInvalidationUnregister, (c_void_p(1), b'DiscoveryInterfaceEvent', <CFunctionType object at 0x000001AA89B862B0>))
2023-02-09 10:08:22,081 | Trace    | Leave |       vimba.c_binding.vimba_c.call_vimba_c
2023-02-09 10:08:22,081 | Trace    | Leave |     vimba.feature._BaseFeature.__unregister_callback
2023-02-09 10:08:22,081 | Trace    | Enter |     vimba.shared.remove_feature_accessors(<vimba.vimba.Vimba.__Impl object at 0x000001AA89B782E0>, (Feature(_handle=c_void_p(1),_info=VmbFeatureInfo(name=b'ActionCommand',featur ...
2023-02-09 10:08:22,081 | Trace    | Leave |     vimba.shared.remove_feature_accessors
2023-02-09 10:08:22,081 | Trace    | Enter |     vimba.c_binding.vimba_c.call_vimba_c(VmbShutdown, ())
2023-02-09 10:08:22,429 | Trace    | Leave |     vimba.c_binding.vimba_c.call_vimba_c
2023-02-09 10:08:22,429 | Trace    | Leave |   vimba.vimba.Vimba.__Impl._shutdown
2023-02-09 10:08:22,429 | Trace    | Leave | vimba.vimba.Vimba.__Impl.__exit__

Thanks

Teresa-AlliedVision commented 1 year ago

Hello, we found the issue and the workaround Niklas and I decided on is the following: When you discover the camera with an ID, then that ID (which will be the IP-address) is saved into the camera info and will overwrite the id saved in the camera info by default. cameraIdString in camera info is not the IP-address in the C-API, so this will be different behaviour to the C-API. The line info.cameraIdString = id_.encode('utf-8') in camera.py in discover_camera is the only addition together with the first workaround. Please note that when no broadcast packages are enabled, then the camera list does not update, because there are no camera events. So with these workarounds, the camera list in your python program will not display accurately if a camera already is opened or not. This would in theory allow you to have two Python camera objects for the same real camera, but opening both during runtime will throw an error. So you need to carefully manage the camera objects in your code and make sure that you only discover each camera once. Also, if you discover the same camera with two different IDs, then even if you check the camera objects or camera info against each other, they will not be recognized as being the same real camera.

This diff file includes both changes for the workaround with blocked network discovery:

diff --git a/vimba/camera.py b/vimba/camera.py
index 843a5b5..7756079 100644
--- a/vimba/camera.py
+++ b/vimba/camera.py
@@ -1060,7 +1060,7 @@ def discover_camera(id_: str) -> Camera:
     # Try to lookup Camera with given ID. If this function
     try:
         call_vimba_c('VmbCameraInfoQuery', id_.encode('utf-8'), byref(info), sizeof(info))
-
+        info.cameraIdString = id_.encode('utf-8')
     except VimbaCError as e:
         raise VimbaCameraError(str(e.get_error_code())) from e

diff --git a/vimba/vimba.py b/vimba/vimba.py
index 8c05b51..2dc52ed 100644
--- a/vimba/vimba.py
+++ b/vimba/vimba.py
@@ -290,6 +290,7 @@ class Vimba:
                     for cam in self.__cams:
                         if cam_info.get_id() == cam.get_id():
                             return cam
+                    return cam_info

                 except VimbaCameraError:
                     pass

This is a diff file, that can be applied to your local branch: https://stackoverflow.com/questions/12320863/how-do-you-take-a-git-diff-file-and-apply-it-to-a-local-branch-that-is-a-copy-o

Please note: This workaround is not the official branch and can cause unknown behaviour in your program. Make sure to change back to the official source code, if the workaround is no longer needed. It is recommended to clearly mark the changes you make in your local source code.

ivanrajkovic commented 1 year ago

I patched both changes and it works now, I get frames with synchronous_grab.py example. Didn't test anything else for now.

Thanks, Ivan

ozen commented 1 year ago

I think even if this eliminates the need for broadcast messages (I haven't checked the traffic dump myself), the camera still needs to be on the same subnet with the host.

I thought the need to be on the same subnet is caused by the broadcast messages!

However, the above patch didn't help with that situation.

First, VmbCameraInfoQuery call raised Not Found error. Then I constructed VmbCameraInfo struct myself, but this time the first VmbCameraOpen call raised Not Found error. All codes I tried work if the camera and the host are on the same subnet, but otherwise don't. For example; host: 172.20.40.10, camera: 172.20.40.11 -> Works host: 172.20.50.10, camera: 172.20.40.11 -> Camera Not Found while the camera answers to ping 172.20.40.11 in both cases.

ivanrajkovic commented 1 year ago

I haven't tested connecting to the camera on /16 subnet, I'll try that next week.

For example; host: 172.20.40.11, camera: 172.20.40.11 -> Works

I hope this is a mistype and you didn't have both camera and computer use the same IP.

host: 172.20.50.11, camera: 172.20.40.11 -> Camera Not Found

Which subnet masks (for both host and camera) are you using, 255.255.0.0 or 255.255.255.0?

ozen commented 1 year ago

I haven't tested connecting to the camera on /16 subnet, I'll try that next week.

For example; host: 172.20.40.11, camera: 172.20.40.11 -> Works

I hope this is a mistype and you didn't have both camera and computer use the same IP.

host: 172.20.50.11, camera: 172.20.40.11 -> Camera Not Found

Which subnet masks (for both host and camera) are you using, 255.255.0.0 or 255.255.255.0?

Sorry, yes, there were typos in the IP addresses that are now fixed.

Subnet masks are 255.255.255.0, I guess otherwise they would be in the same subnet and work, but what I'm testing is different subnets.

Note that there is no problem in the routing, I can send pings to the camera.

ivanrajkovic commented 1 year ago

Well, I will not be able to test this kind of network setup with my camera. I hope you get some help from AlliedVision.

Teresa-AlliedVision commented 1 year ago

The camera and adapter/host need to be in the same subnet. Please refer to the "User Guide" for the specific settings the camera and host should have. Depending on the camera model, the information can be on different pages, but should be under the section "Configuring the host computer" for all models.

Alvium G1 and G5 Documentation Manta Documentation Mako Documentation

ozen commented 1 year ago

The camera and adapter/host need to be in the same subnet. Please refer to the "User Guide" for the specific settings the camera and host should have. Depending on the camera model, the information can be on different pages, but should be under the section "Configuring the host computer" for all models.

Alvium G1 and G5 Documentation Manta Documentation Mako Documentation

Thanks. But I wonder the technical reason of this limitation.