genicam / harvesters

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

AccessDeniedException - USB-API not available #353

Closed fuzzdoug closed 2 years ago

fuzzdoug commented 2 years ago

Describe the Issue I get an AccessDeniedException when running the sample code from the Readme - Harvester on IPython. https://github.com/genicam/harvesters#harvester-on-ipython

To Reproduce Steps to reproduce the behavior:

  1. Run IPython
  2. Run the Code

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

If yes, please provide a sample code:

from harvesters.core import Harvester
import numpy as np  # This is just for a demonstration.

h = Harvester()
h.add_file('mvGenTLProducer.cti')
h.update()
len(h.device_info_list)
h.device_info_list[0]

ia = h.create(0)

If applicable, please paste the actual output (its whole traceback, etc) here:

Python 3.8.13 | packaged by conda-forge | (default, Mar 25 2022, 05:59:00) [MSC v.1929 64 bit (AMD64)]
Type 'copyright', 'credits' or 'license' for more information
IPython 7.33.0 -- An enhanced Interactive Python. Type '?' for help.

In [1]: from harvesters.core import Harvester

In [2]: import numpy as np

In [3]: h = Harvester()

In [4]: h.add_file('mvGenTLProducer.cti')

In [5]: h.update()

In [6]: len(h.device_info_list)
Out[6]: 1

In [7]: h.device_info_list[0]
Out[7]: {'access_status': 1, 'display_name': 'JAI Ltd., Japan VID14FB_PID100B_U500373', 'id_': 'VID14FB_PID100B_U500373', 'model': 'GO-5000C-USB', 'parent': <genicam.gentl.Interface; proxy of <Swig Object of type 'std::shared_ptr< GenTLCpp::TLInterface > *' at 0x0000023D1DBB9030> >, 'serial_number': 'U500373', 'tl_type': 'U3V', 'user_defined_name': 'JAI', 'vendor': 'JAI Ltd., Japan', 'version': '0.1.0.1'}

In [8]: ia = h.create(0)
---------------------------------------------------------------------------
AccessDeniedException                     Traceback (most recent call last)
<ipython-input-8-cc5ffa9cfbeb> in <cell line: 1>()
----> 1 ia = h.create(0)

~\.conda\envs\genicam\lib\site-packages\harvesters\core.py in create(self, search_key, config)
   2897         assert parent
   2898         device_proxy = Device(module=raw_device, parent=parent)
-> 2899         return self._create_acquirer(device_proxy=device_proxy, config=config)
   2900
   2901     def _create_acquirer(self, *, device_proxy: Device,

~\.conda\envs\genicam\lib\site-packages\harvesters\core.py in _create_acquirer(self, device_proxy, config, file_dict)
   2914                     'not supported: {}'.format(privilege))
   2915
-> 2916             device_proxy.open(_privilege)
   2917             device_proxy_ = Device(module=device_proxy.module, parent=device_proxy.parent)
   2918

~\.conda\envs\genicam\lib\site-packages\harvesters\core.py in m(*args)
    212             else:
    213                 def m(*args):
--> 214                     return getattr(self._source_object, attribute)(*args)
    215                 setattr(self, attribute, m)
    216                 return m

~\.conda\envs\genicam\lib\site-packages\genicam\gentl.py in open(self, accessFlags)
   3187
   3188         """
-> 3189         return _gentl.Device_open(self, accessFlags)
   3190
   3191

AccessDeniedException: GenTL exception: Requested operation is not allowed. (Message from the source: Failed to open device 'VID14FB_PID100B_U500373'. USB-API not available) (ID: -1005)

In [9]:

Expected Behavior Being able to continue with the code in the IPython example.

Configuration

Reproducibility

This phenomenon can be stably reproduced:

If applicable, please provide your observation about the reproducibility.

Tried different drivers and Producers (CTIs), but this seems to be one that "works" the best. Where I actually get meaningful output from "h.device_info_list[0]".

Any help is appreciated.

fuzzdoug commented 2 years ago

Here is some output using another producer CTI and driver.

Driver: JAI libusbx.org 6.1.7600.16385

Python 3.8.13 | packaged by conda-forge | (default, Mar 25 2022, 05:59:00) [MSC v.1929 64 bit (AMD64)]
Type 'copyright', 'credits' or 'license' for more information
IPython 7.33.0 -- An enhanced Interactive Python. Type '?' for help.

In [1]: from harvesters.core import Harvester
   ...: import numpy as np  # This is just for a demonstration.
   ...:
   ...: h = Harvester()
   ...: h.add_file('JaiUSB3vTL.cti')
   ...: h.update()
   ...: len(h.device_info_list)
   ...: h.device_info_list[0]
GenTL producer does not implement DSGetNumBufferParts
GenTL producer does not implement DSGetBufferPartInfo
Out[1]: {'access_status': 3, 'display_name': 'JAI Ltd., Japan GO-5000C-USB (14FB00B7A295)', 'id_': '14FB00B7A295_JAILtdJapan_GO5000CUSB', 'model': 'GO-5000C-USB', 'parent': <genicam.gentl.Interface; proxy of <Swig Object of type 'std::shared_ptr< GenTLCpp::TLInterface > *' at 0x00000134DFA16360> >, 'serial_number': 'U500373', 'tl_type': 'U3V', 'user_defined_name': 'JAI', 'vendor': 'JAI Ltd., Japan', 'version': '0.1.0.1'}

In [2]: ia = h.create(0)
---------------------------------------------------------------------------
AccessDeniedException                     Traceback (most recent call last)
<ipython-input-2-cc5ffa9cfbeb> in <cell line: 1>()
----> 1 ia = h.create(0)

~\.conda\envs\genicam\lib\site-packages\harvesters\core.py in create(self, search_key, config)
   2897         assert parent
   2898         device_proxy = Device(module=raw_device, parent=parent)
-> 2899         return self._create_acquirer(device_proxy=device_proxy, config=config)
   2900
   2901     def _create_acquirer(self, *, device_proxy: Device,

~\.conda\envs\genicam\lib\site-packages\harvesters\core.py in _create_acquirer(self, device_proxy, config, file_dict)
   2914                     'not supported: {}'.format(privilege))
   2915
-> 2916             device_proxy.open(_privilege)
   2917             device_proxy_ = Device(module=device_proxy.module, parent=device_proxy.parent)
   2918

~\.conda\envs\genicam\lib\site-packages\harvesters\core.py in m(*args)
    212             else:
    213                 def m(*args):
--> 214                     return getattr(self._source_object, attribute)(*args)
    215                 setattr(self, attribute, m)
    216                 return m

~\.conda\envs\genicam\lib\site-packages\genicam\gentl.py in open(self, accessFlags)
   3187
   3188         """
-> 3189         return _gentl.Device_open(self, accessFlags)
   3190
   3191

AccessDeniedException: GenTL exception: Requested operation is not allowed. (Message from the source: DeviceOpen: the device is currently not accessible) (ID: -1005)
fuzzdoug commented 2 years ago

Turns out the USB cord was the issue.