ctypes error: libdc1394 error: Failed to initialize libdc1394

放肆的年华 提交于 2019-12-17 10:15:57

问题


I'm trying to compile my program to a shared library that I can use from within Python code using ctypes.

The library compiles fine using this command:

g++ -shared -Wl,-soname,mylib -O3 -o mylib.so -fPIC [files] `pkg-config --libs --cflags opencv`

However, when I try and import it using ctypes

from ctypes import *
mylib = CDLL("/path/to/mylib.so")
print mylib.test() // Expected output: Hello World

I get the following error:

libdc1394 error: Failed to initialize libdc1394

What's going on?


回答1:


Very frustrating that nobody actually shows a concrete solution. I had this issue after installing OpenCV. For me the easiest solution to remove this warning was actually to disable this driver:

sudo ln /dev/null /dev/raw1394



回答2:


libdc1394 is a library for controlling camera hardware. I presume it comes the opencv you link in. Maybe the kernel driver does not load ? I guess there is a number of reasons why it can fail.

Maybe some OpenCV expert can answer better. But I bet the problem is on OpenCV lib side.

Some initial search for the same error message yielded results with the same reason [1, 2]. So if you can't find /dev/raw1394 on your file system try those.

UPDATE:

It seems like this is only a warning. The module raw1394 seems to be deprecated and some libdc1394 version might be looking for it while it disappeared with an update. Searching for it gives many results and bug reports. But it seems that the software should run fine. So if you don't really need it you can just ignore it. [3, 4]




回答3:


Okay. I spent a entire day on it.

Basically, the link between /dev/raw1394 and /dev/null is not permanent. You can bash into your VM, call ln /dev/null /dev/raw1394, but it will last only until you re-start your container.

What I had to do, that seemed to be the simplest, but not the perfect approach, is to place the linking during the startup of the Container.

I thought in Running it as a service, but seemed too much for a simple job.

The way I finally came to work, (it's not pretty, but works), is by changing the CMD of the Dockerfile:

CMD sh -c 'ln -s /dev/null /dev/raw1394'; <your-script-here>




回答4:


I had similar issue with an Ubuntu precise running under VirtualBox. First I installed OpenCV following these instructions: https://help.ubuntu.com/community/OpenCV This fixed several issues I had trying other methods but the problem with libdc1394 was still there.

libdc1394 error: Failed to initialize libdc1394

I finally saw goran comment on the previous answer

So I enabled the USB controller in virtualbox.... et voila! everything works perfectly!

Thanks goran!




回答5:


For folks who compiled their own opencv and encounter this error, and have no need for the firewire video capture support, you can always re-compile with -D WITH_1394=OFF option, like below:

cmake -D CMAKE_BUILD_TYPE=RELEASE -D WITH_1394=OFF ./

If you turn off this option you can even loose the libdc1394-22-dev dependency (ubuntu). Though I've not personally tested this.




回答6:


Another workaround in using a docker image is to mount a volume

docker run -v /dev/null:/dev/raw1394



来源:https://stackoverflow.com/questions/12689304/ctypes-error-libdc1394-error-failed-to-initialize-libdc1394

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!