Python ctypes 错误:libdc1394 错误:无法初始化 libdc1394

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12689304/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-18 11:36:24  来源:igfitidea点击:

ctypes error: libdc1394 error: Failed to initialize libdc1394

pythonc++shared-librariesctypeslibdc1394

提问by fredley

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

我正在尝试将我的程序编译为一个共享库,我可以使用 ctypes 在 Python 代码中使用它。

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

但是,当我尝试使用 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?

这是怎么回事?

采纳答案by Vad

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:

非常令人沮丧的是,实际上没有人给出具体的解决方案。安装 OpenCV 后我遇到了这个问题。对我来说,删除此警告的最简单解决方案实际上是禁用此驱动程序:

sudo ln /dev/null /dev/raw1394

回答by luk32

libdc1394is 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.

libdc1394是一个用于控制相机硬件的库。我认为它来自您链接的 opencv。也许内核驱动程序没有加载?我想它可能失败的原因有很多。

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

也许一些 OpenCV 专家可以更好地回答。但我打赌问题出在 OpenCV lib 方面。

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

对相同错误消息的一些初始搜索产生了具有相同原因的结果 [ 1, 2]。因此,如果您/dev/raw1394在文件系统上找不到,请尝试这些。

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]

这似乎只是一个警告。模块 raw1394 似乎已被弃用,一些 libdc1394 版本可能正在寻找它,而它随着更新而消失。搜索它会提供许多结果和错误报告。但似乎该软件应该可以正常运行。所以如果你真的不需要它,你可以忽略它。[ 3, 4]

回答by jeremie

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

我在 VirtualBox 下精确运行 Ubuntu 时遇到了类似的问题。首先,我按照以下说明安装了 OpenCV:https: //help.ubuntu.com/community/OpenCV 这解决了我尝试其他方法时遇到的几个问题,但 libdc1394 的问题仍然存在。

libdc1394 error: Failed to initialize libdc1394

I finally saw gorancomment on the previous answer

我终于看到goran对上一个答案的评论

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

所以我在 virtualbox 中启用了 USB 控制器......等等!一切正常!

Thanks goran!

谢谢戈兰!

回答by Ivan Seidel

Okay. I spent a entire day on it.

好的。我花了一整天的时间。

Basically, the link between /dev/raw1394and /dev/nullis 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.

基本上,之间的联系/dev/raw1394/dev/null是不是永久性的。您可以 bash 进入您的 VM,调用ln /dev/null /dev/raw1394,但它只会持续到您重新启动容器。

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.

我必须做的,这似乎是最简单但不是完美的方法,是在 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 CMDof the Dockerfile:

我最终开始工作的方式(虽然不漂亮,但有效)是通过更改CMDDockerfile 的:

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

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

回答by Ying-Chi I

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=OFFoption, like below:

对于自己编译opencv遇到这个错误,又不需要火线视频采集支持的人,可以随时用-D WITH_1394=OFFoption重新编译 ,如下图:

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.

如果您关闭此选项,您甚至可以失去 libdc1394-22-dev 依赖项 (ubuntu)。虽然我没有亲自测试过这个。

回答by Syi

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

使用 docker 镜像的另一种解决方法是挂载一个卷

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

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