genicam / harvesters

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

_gentl.ResourceInUseException upon h.update() #334

Open aqc-carlodri opened 2 years ago

aqc-carlodri commented 2 years ago

Describe the Bug Starting from harvesters 1.3.3, when I say h.update() to enumerate the cameras, I get a () _gentl.ResourceInUseException error (see below). The error is not present if I revert to 1.3.2.

To Reproduce See code below

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

If yes, please provide a sample code:

h = Harvester()
h.update()

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

>>> h.update()
2022-04-12 12:32:14,190 :: harvesters.core :: ERROR :: GenTL exception: Requested resource is already in use. (Message from the source: ) (ID: -1004)
Traceback (most recent call last):
  File "C:\Users\xxx\lib\site-packages\harvesters\core.py", line 2849, in update
    raw_iface.open()
  File "C:\Users\xxx\lib\site-packages\genicam\gentl.py", line 2893, in open
    return _gentl.Interface_open(self)
_gentl.ResourceInUseException: GenTL exception: Requested resource is already in use. (Message from the source: ) (ID: -1004)
2022-04-12 12:32:20,309 :: harvesters.core :: ERROR :: GenTL exception: Requested resource is already in use. (Message from the source: ) (ID: -1004)
Traceback (most recent call last):
  File "C:\Users\xxx\lib\site-packages\harvesters\core.py", line 2849, in update
    raw_iface.open()
  File "C:\Users\xxx\lib\site-packages\genicam\gentl.py", line 2893, in open
    return _gentl.Interface_open(self)
_gentl.ResourceInUseException: GenTL exception: Requested resource is already in use. (Message from the source: ) (ID: -1004)

Expected Behavior With harvesters 1.3.2 this problem was not present and the device enumeration completed without errors.

Configuration

Reproducibility

This phenomenon can be stably reproduced:

If applicable, please provide your observation about the reproducibility.

Actions You Have Taken Reverted back to 1.3.2.

Additional context I'm using multiple line scan cameras.

kazunarikudo commented 2 years ago

@aqc-carlodri Hi, thank you for the report. I will try to have a look and get back to you. Regards, Kazunari.

aqc-carlodri commented 2 years ago

Thank you very much @kazunarikudo! Let me know if you need any further diagnosis from my side.

kazunarikudo commented 2 years ago

@aqc-carlodri Hi, excuse me, I would appreciate it if the issue can be reproduced by using version 1.3.8 which is the latest as of today.

aqc-carlodri commented 2 years ago

Hi @kazunarikudo, at the moment I cannot reproduce easily the setup I used when reporting this issue. However, I have the feeling that the issue was related to the Common Vision Blox producer, since when enumerating the cameras, it always shows two instances of the same identical camera (at least, indistinguishable from the metadata available just after a h.update()).

AFAIU the two instances are the raw socket driver and the filter driver instance. This might be an issue by itself: there is not way to distinguish these two instances of the camera, without creating an acquirer and inspecting the driver type.

I see that this has already been reported in https://github.com/genicam/harvesters/issues/231. However, I couldn't find a way to disable the socket driver itself in the Common Vision Blox producer.

I will test ASAP with the Matrix Vision producer, but I expect the issue will not show up.

MathijsNL commented 1 year ago

I get the same error. When I don't use a cti file I don't get an error. Could it be related to the cti file? It does print the device list and the single camera that is attached. Without camera the same error occurs.

Code:

from harvesters.core import Harvester
h = Harvester()

cti = "/lib/GxGVTL.cti"

h.add_file(cti)
print(h.files)

h.update()

print(h.device_info_list)

Error:

2023-01-30 13:32:41,766 :: harvesters.core :: ERROR :: GenTL exception: Requested resource is already in use. (Message from the source: ) (ID: -1004)
MathijsNL commented 1 year ago

I tested it with the Matrix Vision CTI files, and that worked like a charm. No errors.

I did notice that even though there is an error I can still connect to the camera and grab frames without problems. How could I debug this?