2

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.

2
  • I don't like virtual environments like the one Adrian always work with. If you would like to try out my cheat sheet. I don't use virtualenv and it works well on RPI 2 Model B. Hope I helped. Don't forget to fork me on GitHub. To try out my cheat sheet you first have to enter the build directory and execute sudo make clean
    – Tes3awy
    Sep 11, 2016 at 23:37
  • Again everybody is replying about the linux/videodev.h but why none is taking about the sys/videoio.h Sep 23, 2021 at 13:33

5 Answers 5

2

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.

2
  • @EnemyBagJones libv4l-dev. Not just libv4l lol. My answer says: "You can install it by running sudo apt-get install libv4l-dev"
    – Aloha
    Feb 8, 2016 at 13:57
  • I already had this library installed .. so this didn't unfortunately fix the problem, so something else is amiss
    – Levon
    Mar 6, 2016 at 20:55
1

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:-

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

  2. 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 of

    26-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"

1

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 && \
1
  • 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.
    – Ghanima
    Aug 28, 2016 at 10:35
0

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)

0

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

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