genicam / harvesters

Image Acquisition Library for GenICam-based Machine Vision System
Apache License 2.0
500 stars 86 forks source link

Finds device, but throws AccessException (no XML parser error) #446

Open SartorL opened 4 months ago

SartorL commented 4 months ago

Describe the Issue Device and GenTL producer were found without a problem. Could not get ownership of device.

This error is similar to previously reported issue "Python & Critical Link GenTL (XML parser error) #368" AccessException thrown (file 'NodeMapRef.h', line 497) is the same However, I did not get a runtime exception thrown for XmlParser.cpp

To Reproduce Steps to reproduce the behavior: Followed harvesters install: https://github.com/genicam/harvesters/blob/master/docs/INSTALL.rst And tutorial: https://github.com/genicam/harvesters/blob/master/docs/TUTORIAL.rst up to ia = h.create()

Sample Code I can show a piece of code that demonstrates the reported phenomenon:

(base) C:\Users\.......>conda activate genicam

(genicam) C:\Users\.......>python
Python 3.11.7 | packaged by Anaconda, Inc. | (main, Dec 15 2023, 18:05:47) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.

>>> from harvesters.core import Harvester
>>> h = Harvester()
>>> h.files
[]
>>> h.add_file('C:\\Program Files\\Balluff\\ImpactAcquire\\bin\\x64\\mvGenTLProducer.cti')
>>> h.files
['C:\\Program Files\\Balluff\\ImpactAcquire\\bin\\x64\\mvGenTLProducer.cti']
>>> h.update()

>>> print(h.device_info_list)
[{'access_status': 1, 'display_name': 'Xenics Gobi+ 640 GigE(00:1b:aa:01:19:42)', 'id_': 'Gobi+ 640 GigE(00:1b:aa:01:19:42)', 'model': 'Gobi+ 640 GigE', 'parent': <genicam.gentl.Interface; proxy of <Swig Object of type 'std::shared_ptr< GenTLCpp::TLInterface > *' at 0x0000014E920A2A60> >, 'serial_number': '13136', 'thisown': True, 'tl_type': 'GEV', 'user_defined_name': '', 'vendor': 'Xenics', 'version': '1.0.2'}]

>>> ia = h.create({'serial_number': '13136'})

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\.......\anaconda3a\envs\genicam\Lib\site-packages\harvesters\core.py", line 3082, in create
    return self._create_acquirer(device_proxy=device_proxy, config=config)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\.......\anaconda3a\envs\genicam\Lib\site-packages\harvesters\core.py", line 3112, in _create_acquirer
    ia = ImageAcquirer(device_proxy=device_proxy_, config=config,
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\.......\anaconda3a\envs\genicam\Lib\site-packages\harvesters\core.py", line 1631, in __init__
    self._remote_device = RemoteDevice(
                          ^^^^^^^^^^^^^
  File "C:\Users\.......\anaconda3a\envs\genicam\Lib\site-packages\harvesters\core.py", line 485, in __init__
    super().__init__(
  File "C:\Users\.......\anaconda3a\envs\genicam\Lib\site-packages\harvesters\core.py", line 281, in __init__
    self._node_map = self._create_node_map(
                     ^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\.......\anaconda3a\envs\genicam\Lib\site-packages\harvesters\core.py", line 355, in _create_node_map
    node_map.connect(concrete_port, port.name)
  File "C:\Users\.......\anaconda3a\envs\genicam\Lib\site-packages\genicam\genapi.py", line 1950, in connect
    return self._connect(*args)
           ^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\.......\anaconda3a\envs\genicam\Lib\site-packages\genicam\genapi.py", line 1860, in _connect
    return _genapi.NodeMap__connect(self, *args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
_genapi.AccessException: Feature not present (reference not valid) : AccessException thrown (file 'NodeMapRef.h', line 497)
>>>

Configuration

Reproducibility

This phenomenon can be stably reproduced:

Actions You Have Taken

sunavlis commented 3 months ago

Hi @SartorL

Thanks for your bug report. It looks quite weird. I'm not sure why you get this error message, but maybe something is wrong with the provided XML file.

Could you run your script with enabled debug logging?

import logging
from harvesters.core import Harvester
FORMAT = '%(name)s - %(asctime)s: %(message)s'
logging.basicConfig(level=logging.DEBUG, format=FORMAT)

h = Harvester(logger=logging.getLogger("harvesters"))
....

In the log you will see few temporary path to the XML. Could you try to get that file as well? I just realized, that the _do_cleanup flag is not propagated to the Device module. But maybe you have another option to read the camera XML...?