Error when opening DeviceFactory: RuntimeError C-API call failed, LoadImageFileW

Hello,

I am trying to connect a camera via the CVB Python wrapper.

When I start with the following simple Python code…

import cvb
GenICamDevice = cvb.DeviceFactory.open(cvb.install_path()+"/Drivers/GenICam.vin")

, I very often (and sometimes very persistently) get the following error message:

Traceback (most recent call last):

  File "<ipython-input-3-bcd6810e309b>", line 1, in <module>
    GenICamDevice = cvb.DeviceFactory.open(cvb.install_path()+"/Drivers/GenICam.vin")

RuntimeError: {C-API call failed} ({LoadImageFileW})

The installation was done according to the example in this forum. It has also already worked before, so the camera and / or installation seems principally correct.
Running the CVB Management Console shows, that the camera is working (sending images).

Can anybody help me, solving the problem? Do you need more information?

My system:
Win 10
Python 3.6.5 (run via Spyder)
Common Vision Blox Bindings 1.00.000 (x64)
CommonVisionBlox 13.01.006 (x64).exe
Camera (Dalsa Nano) connected via GigE and PoE injector

Hi Tom,

welcome to our forum.

One obvious question first:
When you run your code, are all other applications that could possibly block the driver closed (eg. ManagementConsole)?

Cheers
Chris

Hi Chris,

Currently (after a complete restart) it’s working (with ManagementConsole closed).
But before I tried it both with and without ManagementConsole.

I figured that after startup of the computer, I can only run my test program after I had made a quick shot with the ManagementConsole before.
And after stopping a Python code, it can be only re-run without above error, after killing the Python interpreter.

Could it be that there are still processes running in the background? If so, can I identify them somehow?

Best wishes and thanks for your help,
Tom

Do you launch your application from autostart?

No, from within Spyder (Python IDE).

Hi @Tom

As the error says the call fails at the C-API level. Therefore it is most likely that it has nothing to do with Python in general.

But as you wrote:

Unfortunately that is quite common as Python and especially Spider is not very transparent about resource management. I suggest using the the “with” statement.

with cvb.DeviceFactory.open(...) as device:
  pass # do something with the device here, the device will be closed after you left the with scope

For a quick check if the device is accessible you can run GenICam Browser to discover devices, a red camera icon indicates that the device is currently inaccessible.

1 Like

Hi Andreas,

Opening with the “with” statement works without errors. So the problem is solved.

Thanks,
Tom

1 Like