69

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?

7 Answers 7

188

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
7
  • 1
    this is the answer you are looking for - if you arent using the hardware but using CV2! Mar 16, 2015 at 20:53
  • 3
    This solution doesn't seem to be permanent on debian. After a restart the link is gone. How to make it permanent?
    – Christian
    Jun 17, 2015 at 6:12
  • 3
    I guess that to make it permanent it should be enough to add ln /dev/null /dev/raw1394 to /etc/rc.local (just before exit 0 line) Apr 5, 2016 at 17:42
  • 1
    Works like a charm! Ran into some trouble installing caffe on AWS. You saved the day. Apr 30, 2016 at 17:34
  • 1
    Same issue using OpenAlpr with "alpr" command line. The issue gone using this solution; anyway it this not clear on this thread why it happens May 18, 2016 at 0:40
31

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]

6
  • 1
    We don't need to use camera hardware, is there perhaps a way of compiling without that part of OpenCV?
    – fredley
    Oct 2, 2012 at 11:26
  • The fix for /dev/raw1394 does not seem to work, I get FATAL: Module raw1394 not found. from modprobe
    – fredley
    Oct 2, 2012 at 11:32
  • 4
    I saw this issue when running under a virtual machine (VMWare Fusion Ubuntu 14.04 Django Stack from Bitnami) that didn't have a USB controller installed. After I added a USB controller to the VM this error went away.
    – goran
    Sep 10, 2014 at 18:32
  • Similarly to @goran, I saw this running a VM - VirtualBox 4.3.28 running CoreOS 647.0.0, therein running Docker 1.5.0 with a Fedora 21 image. The error popped up with an >>> import cv2 within the Fedora image.
    – kdbanman
    May 26, 2015 at 21:13
  • 1
    @ArthurTacca I've edited this answer to make the finding that it's safe to ignore more prominent. The last edit was from 2012 when this finding was fresh and not so certain.
    – luk32
    Jan 12, 2017 at 12:23
9

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>

1
  • Alternatively, you can add RUN echo 'ln /dev/null /dev/raw1394' >> ~/.bashrc and keep your CMD intact
    – Paglian
    Jun 29, 2016 at 14:33
6

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!

3
  • 3
    This should be a comment, not an additional answer.
    – paisanco
    Sep 17, 2014 at 20:45
  • 1
    I was not registered when answering the post, now I'm registered but do not have enough reputation to move this message into the comments, sorry
    – jeremie
    Sep 17, 2014 at 21:11
  • @jeremie I am using Virtual Box and ubuntu 14.04 is running on it, USB contoller is enables but still i am getting the same message - libdc1394 error: Failed to initialize libdc1394 , I am running a docker container in which openCV is installed
    – kkk
    Jan 19, 2016 at 2:49
4

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.

3

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

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

1
  • How and why does this work? Will this enable me to use a webcam? May 30, 2017 at 14:30
0

I had the same problem. solved by running tsu first and then debian.

problem:

./start-debian.sh
root@localhost:~# python3 -c "import cv2; print(cv2.__version__)"
libdc1394 error: Failed to create juju: opendir: Permission denied
libdc1394 error: Failed to initialize libdc1394
3.2.0
root@localhost:~#

tsu
./start-debian.sh
root@localhost:~# python3 -c "import cv2; print(cv2.__version__)"
3.2.0
root@localhost:~# 

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.