, 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
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?
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.
I am having the same issue that @Tom described, however none of the proposed solutions have fixed my problem. My error message also is less specific.
RuntimeError Traceback (most recent call last)
<ipython-input-11-efb389850ddd> in <module>
----> 1 with cvb.DeviceFactory.open(cvb.install_path() + "drivers\GenICam.vin") as device:
2 pass
RuntimeError: C-API call failed
I am working in JupyterLab instead of Spyder.
The camera I am trying to find is connected by USB and shows up green when I check in the ManagementConsole.
Other cvb functions seem to be working just fine.
Sadly neither "drivers\\GenICam.vin" nor "\drivers\\GenICam.vin"changes anything.
If anyone has an idea where I should be looking to find the cause of the issue (file paths, module documentation, etc.) that would also be incredible helpful.
I assume this is running on Windows. I would then expect cvb.install_path() to point to something like C:\Program Files\STEMMER IMAGING\Common Vision Blox\ (mind the trailing \\ and the double backslashes). If you can confirm that for your system then I would expect "Drivers\\GenICam.vin" to work (upper/lower case should not be an issue).
Just to be sure: You did configure and save a suitable “GenICam.ini” file with the GenICamBrowser? That is actually needed for this approach to opening. And the GenICamBrowser is closed when you call open?
I am running everything on Windows and print(cvb.install_path()) returns "C:\Program Files\STEMMER IMAGING\Common Vision Blox\" just like you said.
I didn’t explicitly configured the file by hand, but there is a “GenICam.ini” at the end of the file path "C:\ProgramData\STEMMER IMAGING\Common Vision Blox\Drivers".
The camera I want to use shows up and is green in the GenICamBrowser.
And yes, the GenICamBrowser is closed while I am trying to access the camera.
it is not sufficient that the camera is visible on the left hand side in the GCBrowser. What is needed (and what @illusive meant) is the configuration of that device into the right hand section called “Configured Devices”
Thanks for the advice @illusive and @s-woe, turns out i was missing the actual configuration because I had an issue actually saving the configuration file.
Once that issue was resolved, the configuration could be saved and the RuntimeError: C-API call failed disappeared.
The program still freezes and doesn’t do what it is supposed to, but that is a problem for another thread.
Did/Do you by any change abort the execution of the program, i.e. during a successful run?
Or another execption is uncatched?
Or does it exit normally?
Background for this question is, that a camera depending on the camera technology might be in an undefined state, if an appliction uses the camera crashes.
I.e. catch all exceptions.
However this is an assuption, not really sure if this relates to your issue.
At the moment the image processing code takes only a file as input and doesn’t have anything to do with accessing the camera. I do not throw any exceptions in my code.
I am opening the device using a with statement, and I am manually aborting the stream afterwards (see below).
Does stream.abort() not release the camera? What should I be using instead?
with cvb.DeviceFactory.open("C:\Program Files\STEMMER IMAGING\Common Vision Blox\Drivers\GenICam.vin") as device:
stream = device.stream()
stream.start()
image, status = stream.wait()
if status == cvb.WaitStatus.Ok:
image.save("acquired_image.jpg")
# image processing code:
ri_1 = rip.rectangle_image("acquired_image.jpg")
ri_1.evaluate_image(high_threshold=200, low_threshold=100)
stream.abort()