All, I've followed these instructions: installing OpenCV 3.0 on raspberry pi b+
and these: http://www.pyimagesearch.com/2015/10/26/how-to-install-opencv-3-on-raspbian-jessie/#comment-389260
and neither work, because I keep getting the following fatal errors.
pi@raspberrypi:~/opencv-3.1.0/build $ cat /home/pi/opencv-3.1.0/build/CMakeFiles/CMakeError.log | grep fatal
/home/pi/opencv-3.1.0/build/CMakeFiles/CMakeTmp/CheckIncludeFile.c:1:28: fatal error: linux/videodev.h: No such file or directory
/home/pi/opencv-3.1.0/build/CMakeFiles/CMakeTmp/CheckIncludeFile.c:1:25: fatal error: sys/videoio.h: No such file or directory
/home/pi/opencv-3.1.0/build/CMakeFiles/CMakeTmp/CheckIncludeFile.c:1:29: fatal error: ffmpeg/avformat.h: No such file or directory
I've tried restarting from scratch with a new image of Jessie twice now, and I've scoured the internet and I keep turning up empty handed. Any guidance would be much appreciated. Thanks.
5 Answers 5
You need the libv4l
library. You can install it by running sudo apt-get install libv4l-dev
.
In addition, you may also need additional libraries to compile OpenCV properly. Running the command sudo apt-get build-dep opencv
should get you everything you need.
-
@EnemyBagJones
libv4l-dev
. Not justlibv4l
lol. My answer says: "You can install it by runningsudo apt-get install libv4l-dev
"Aloha– Aloha2016年02月08日 13:57:16 +00:00Commented Feb 8, 2016 at 13:57 -
I already had this library installed .. so this didn't unfortunately fix the problem, so something else is amissLevon– Levon2016年03月06日 20:55:25 +00:00Commented Mar 6, 2016 at 20:55
Scouring internet for possible solution of the exact same issue I faced landed me here and no solution specified worked. What I did notice though is:-
Not all steps described in the pyimagesearch blog were followed - missed some steps - checked one by one though not sure this was the root cause.
OpenCV 3.1.0 has a bug and you need to set
INSTALL_C_EXAMPLES=OFF
. This info is available as an update in the pyimagesearch blog of26-10-2015:- "Update (3 January 2016): In order to build OpenCV 3.1.0 , you need to set -D INSTALL_C_EXAMPLES=OFF (rather than ON ) in the cmake command. There is a bug in the OpenCV v3.1.0 CMake build script that can cause errors if you leave this switch on. Once you set this switch to off, CMake should run without a problem"
To fix the first line, you should install the libv4l-dev
package and manually link header files:
sudo apt-get install libv4l-dev
cd /usr/include/linux/
sudo ln -s ../libv4l1-videodev.h videodev.h
About the last line:
sudo mkdir /usr/include/ffmpeg && \
sudo ln -sf /usr/include/libavcodec/*.h /usr/include/ffmpeg && \
sudo ln -sf /usr/include/libavformat/*.h /usr/include/ffmpeg && \
sudo ln -sf /usr/include/libswscale/*.h /usr/include/ffmpeg && \
-
Welcome to Raspberry Pi! Whilst this may theoretically answer the question, it would be preferable to include some explanation here, e.g. what do these commands do? Please take the tour and visit the helpcenter to see how things work here.2016年08月28日 10:35:11 +00:00Commented Aug 28, 2016 at 10:35
I got the exact same errors too - then I saw, it was a typo... If in the cmake command, the path to the extra modules is wrong, you run into these errors. Therefore be sure, that the directory of the opencv_contrib files is allright, for v. 3.1.0, it should be:
-D OPENCV_EXTRA_MODULES_PATH=~/opencv_contrib-3.1.0/modules
(and not ...~/opencv_contrib-3.0.0/... what you get when you copy/paste the instructions you mentioned)
A in my case, probably as silly as you get an example to compile/build from older versions.
Check your references are right.
$ cd ~/opencv-3.4.0/
$ mkdir build
$ cd build
$ cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D INSTALL_PYTHON_EXAMPLES=ON -D OPENCV_EXTRA_MODULES_PATH=~/opencv_contrib-3.4.0/modules -D BUILD_EXAMPLES=ON ..
sudo make clean
linux/videodev.h
but why none is taking about thesys/videoio.h