Home > Linux, Vision > Tips and Tricks: A Comprehensive OpenCV Installation Troubleshooting Guide

Tips and Tricks: A Comprehensive OpenCV Installation Troubleshooting Guide

From: http://ozbots.org/opencv-install-troubleshooting/

[Revised 2011-08-29. See Change Log section for revision information.]

This guide lists solutions for problems you might encounter when installing OpenCV and its dependencies. Many of the problems are related to using webcams. This guide is a companion guide to “A Comprehensive Guide to Installing and Configuring OpenCV 2.3 on Ubuntu,” which can be found on ozbots.org.The problems are listed in the sequence that they might occur during a typical OpenCV install. If the problem is accompanied by an error message, the relevant part of the message is highlighted in yellow.

Here is a list of error messages that are addressed by this guide:

  • ERROR: libx264 not found
  • undefined reference to ‘x264_encoder_open_116′
  • libv4lconvert-priv.h:25:21: fatal error: jpeglib.h: No such file or directory
  • libv4l1.c:53:28: fatal error: linux/videodev.h: No such file or directory
  • /home/osman/src/opencv/OpenCV-2.3.0/modules/highgui/src/cap_ffmpeg_impl.hpp:492:13: error: ‘CODEC_TYPE_VIDEO’ was not declared in this scope
  • libv4lconvert: warning more framesizes then I can handle!
  • [swscaler @ 0x89c3e30]No accelerated colorspace conversion found from yuv420p to bgr24.
  • error while loading shared libraries: libopencv_core.so.2.3: cannot open shared object file: No such file or directory
  • VIDIOC_DQBUF: Input/output error
  • VIDIOC_QUERYMENU: Invalid argument

 

Problems Building ffmpeg

Problem
<84> .../ffmpeg$ ./configure --enable-gpl --enable-libfaac --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libtheora --enable-libvorbis --enable-libx264 --enable-libxvid --enable-nonfree --enable-postproc --enable-version3 --enable-x11grab
ERROR: libx264 not found

Solution
Use ffmpeg version 0.7.x. This error occurs if you configure ffmpeg version 0.6.x with the options shown above.

 

Problem
<84> .../ffmpeg$ make
LD ffmpeg_g
libavcodec/libavcodec.a(libx264.o): In function `X264_init':
/home/osman/src/ffmpeg/ffmpeg-0.7.3/libavcodec/libx264.c:395: undefined reference to 'x264_encoder_open_116'
collect2: ld returned 1 exit status
make: *** [ffmpeg_g] Error 1
Solution
Rebuild x264 and ffmpeg with the shared library option. To rebuild x264, change to the directory where you untared the x264 source files, and enter the following commands:
./configure --enable-shared --enable-pic
make
sudo make install

To rebuild ffmpeg, change to the directory where you untared the ffmpeg source files, and enter the following commands:

./configure --enable-gpl --enable-libfaac --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libtheora --enable-libvorbis --enable-libx264 --enable-libxvid --enable-nonfree --enable-postproc --enable-version3 --enable-x11grab --enable-shared
make
sudo make install

This solution comes from http://www.linuxquestions.org/questions/linux-newbie-8/problem-with-enable-libx264-option-in-ffmpeg-822156/page2.html.

 

Problems Building v4l

Problem
<37> .../v4l-utils-0.8.4 $ make
make -C lib all
make[1]: Entering directory `/home/osman/src/v4l/v4l-utils-0.8.4/lib'
make -C libv4lconvert all
make[2]: Entering directory `/home/osman/src/v4l/v4l-utils-0.8.4/lib/libv4lconvert'
cc -Wp,-MMD,"libv4lconvert.d",-MQ,"libv4lconvert.o",-MP -c -I../include -fvisibility=hidden -fPIC -DLIBDIR=\"/usr/local/lib\" -DLIBSUBDIR=\"libv4l\" -I../../include -I../../lib/include -D_GNU_SOURCE -DV4L_UTILS_VERSION='"0.8.4"' -g -O1 -Wall -Wpointer-arith -Wstrict-prototypes -Wmissing-prototypes -o libv4lconvert.o libv4lconvert.c
In file included from libv4lconvert.c:26:0:
libv4lconvert-priv.h:25:21: fatal error: jpeglib.h: No such file or directory compilation terminated.
make[2]: *** [libv4lconvert.o] Error 1
Solution
Install libjpeg. See “A Comprehensive Guide to Installing and Configuring OpenCV 2.3 on Ubuntu.”

 

Problem
<37> .../v4l-utils-0.8.4 $ make
...
cc -Wp,-MMD,"libv4l1.d",-MQ,"libv4l1.o",-MP -c -I../include -fvisibility=hidden -fPIC -I../../include -D_GNU_SOURCE -g -O1 -Wall -Wpointer-arith -Wstrict-prototypes -Wmissing-prototypes -o libv4l1.o libv4l1.c
libv4l1.c:53:28: fatal error: linux/videodev.h: No such file or directory
compilation terminated.
make[2]: *** [libv4l1.o] Error 1

Solution
Use v4l-utils-0.8.4 or later. This problem occurs when trying to compile an old version of v4l in Ubuntu 11.x. I have not seen this problem on Ubuntu 10.x.

 

Problems Building OpenCV

Problem
Make fails at around 30% with an error building cap_ffmeg.o. This error might look like this:
[ 29%] Building CXX object modules/highgui/CMakeFiles/opencv_highgui.dir/src/cap_ffmpeg.o
In file included from /home/osman/src/opencv/OpenCV-2.3.0/modules/highgui/src/cap_ffmpeg.cpp:45:0:
/home/osman/src/opencv/OpenCV-2.3.0/modules/highgui/src/cap_ffmpeg_impl.hpp: In member function ‘bool CvCapture_FFMPEG::reopen()’:

/home/osman/src/opencv/OpenCV-2.3.0/modules/highgui/src/cap_ffmpeg_impl.hpp:492:13: error: ‘CODEC_TYPE_VIDEO’ was not declared in this scope
...
/home/osman/src/opencv/OpenCV-2.3.0/modules/highgui/src/cap_ffmpeg_impl.hpp:828:10: error: ‘AVERROR_NUMEXPECTED’ was not declared in this scope
/home/osman/src/opencv/OpenCV-2.3.0/modules/highgui/src/cap_ffmpeg_impl.hpp:832:10: error: ‘AVERROR_NOFMT’ was not declared in this scope
/home/osman/src/opencv/OpenCV-2.3.0/modules/highgui/src/cap_ffmpeg_impl.hpp:834:10: error: ‘AVERROR_IO’ was not declared in this scope
/home/osman/src/opencv/OpenCV-2.3.0/modules/highgui/src/cap_ffmpeg_impl.hpp:836:10: error: ‘AVERROR_NOMEM’ was not declared in this scope

Solution
Install ffmpeg version 0.7.x. You are probably have version 0.8.x installed, which is not compatible with OpenCV 2.3.

 

Problems running a program using OpenCV libraries

Problem
$ ./my_webcam_program
libv4lconvert: warning more framesizes then I can handle!

Solution
Install v4l version 0.8.4 or later, and then run sudo ldconfig. Rerun your program; the message should go away. Note: I don’t really know in what version of v4l this was fixed, but I do know that it is fixed in version 0.8.4.

 

Problem
$ ./my_webcam_program
[swscaler @ 0x89c3e30]No accelerated colorspace conversion found from yuv420p to bgr24.
[swscaler @ 0x8893810]No accelerated colorspace conversion found from yuv420p to bgr24.
[swscaler @ 0x889c5b0]No accelerated colorspace conversion found from yuv420p to bgr24.
Last message repeated 1 times

Solution
The “accepted” solution is to rebuild x264 and ffmpeg with the shared library option. To rebuild x264, change to the directory where you untared the x264 source files, and enter the following commands:
./configure --enable-shared --enable-pic
make
sudo make install

To rebuild ffmpeg, change to the directory where you untared the ffmpeg source files, and enter the following commands:./configure --enable-gpl --enable-libfaac --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libtheora --enable-libvorbis --enable-libx264 --enable-libxvid --enable-nonfree --enable-postproc --enable-version3 --enable-x11grab --enable-shared
make
sudo make install

After rebuilding x264 and ffmpeg, you do not need to rebuild OpenCV. If the swscaler message still occurs when you run your program, run sudo ldconfig, and run your program again.

This solution comes from the following thread on ubuntuforums.org: http://ubuntuforums.org/showthread.php?t=1471616

Unfortunately for me, configuring and recompiling x264 and ffmpeg does not make the warning meesage go away. If try the solution above, please let me know in the comments if it works for you.

 

Problem
$ ./my_webcam_program
error while loading shared libraries: libopencv_core.so.2.3: cannot open shared object file: No such file or directory

Solutions (choose one)
1. Complete the “Configure Linux” step of the guide “A Comprehensive Guide to Installing and Configuring OpenCV 2.3 on Ubuntu.”
2. Set your LD_LIBRARY_PATHenvironment variable, as shown in the following example:export LD_LIBRARY_PATH=/usr/local/libReplace /usr/local/lib with the path where the OpenCV libraries are installed on your system.

 

Problem
VIDIOC_DQBUF: Input/output error
libv4l2: error converting / decoding frame data: v4l-convert: libjpeg error: Start Of Frame 0xc0: width=640, height=480, components=175
VIDIOC_DQBUF: Input/output error
libv4l2: error converting / decoding frame data: v4l-convert: libjpeg error: End Of Image

Solution
Make sure that your webcam is connected to a high-speed USB 2.0 port. I have seen this problem occur when my webcam was connected to a slower full-speed USB port.

 

Problem
<19> .../test1 $ ./my_webcam_program
VIDIOC_QUERYMENU: Invalid argument
VIDIOC_QUERYMENU: Invalid argument
VIDIOC_QUERYMENU: Invalid argument
VIDIOC_QUERYMENU: Invalid argument
VIDIOC_QUERYMENU: Invalid argument
VIDIOC_QUERYMENU: Invalid argument
VIDIOC_QUERYMENU: Invalid argument

Solution
I have not found a solution to this problem. If you know a solution, please let me know! The message is coming from v4l. The message occurs when a webcam is initialized. I think that my webcam, a Logitech C910, does not conform to the UVC specification, and v4l has trouble querying the parameters of the webcam. I can still get frames from the webcam, so I just ignore the message.

 

Change Log

  • 2011-08-29 Added solution for ffmpeg make error undefined reference to 'x264_encoder_open_116'
Advertisements
Categories: Linux, Vision
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: