I have a Pi running a fresh Arch Linux installation and I want to install OpenCV 3, but I am facing an error that I do not have when installing OpenCV on my other computers. I wrote a script that works on my other Arch computers, 'opencv' installed by pacman is just OpenCV 2 but I want 3:
#!/bin/bash
# Install opencv with extras and contrib from git
# Tested on ArchLinux
HOME_DIR=/home/counter
# Go to home dir
cd $HOME_DIR
# Install all needed dependencies
sudo pacman -S opencv pkg-config gtkglext intel-tbb libdc1394 openexr xine-lib eigen python-numpy python2-numpy cmake mesa mesa-libgl gstreamer gstreamer0.10-base gst-plugins-base-libs v4l-utils ffmpeg protobuf git wget curl
# Install optional dependencies
sudo pacman -S libcl # For coding with OpenCL
sudo ldconfig
# Download all needed files
# It's always slow on first time but when interrupted and started again it's much faster
git clone https://github.com/Itseez/opencv.git
git clone https://github.com/Itseez/opencv_contrib.git
git clone https://github.com/Itseez/opencv_extra.git
# Start building
cd $HOME_DIR/opencv
mkdir build
cd $HOME_DIR/opencv/build
cmake -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=/usr/local -D OPENCV_EXTRA_MODULES_PATH=$HOME_DIR/opencv_contrib/modules $HOME_DIR/opencv/build -D OPENCV_TEST_DATA_PATH=$HOME_DIR/opencv_extra -D BUILD_opencv_highgui=OFF -D BUILD_PYTHON_SUPPORT=ON -D BUILD_EXAMPLES=ON ..
# -D BUILD_opencv_dnn=OFF on errors with libprotobuf
make -j5
# Install them
echo "Install OpenCV"
sudo make install
sudo ldconfig
But when running cmake there occurs an error:
cmake -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=/usr/local -D OPENCV_EXTRA_MODULES_PATH=$HOME_DIR/opencv_contrib/modules $HOME_DIR/opencv/build -D OPENCV_TEST_DATA_PATH=$HOME_DIR/opencv_extra -D BUILD_opencv_highgui=OFF -D BUILD_PYTHON_SUPPORT=ON -D BUILD_EXAMPLES=ON ..
-- Detected version of GNU GCC: 53 (503)
-- Found ZLIB: /lib/libz.so (found suitable version "1.2.8", minimum required is "1.2.3")
-- Found ZLIB: /lib/libz.so (found version "1.2.8")
-- Found OpenEXR: /lib/libIlmImf.so
-- Checking for module 'gtk+-3.0'
-- Package 'gtk+-3.0' not found
-- Looking for linux/videodev.h
-- Looking for linux/videodev.h - not found
-- Looking for linux/videodev2.h
-- Looking for linux/videodev2.h - found
-- Looking for sys/videoio.h
-- Looking for sys/videoio.h - not found
-- Looking for libavformat/avformat.h
-- Looking for libavformat/avformat.h - found
-- Looking for ffmpeg/avformat.h
-- Looking for ffmpeg/avformat.h - not found
-- Checking for module 'libgphoto2'
-- Package 'libgphoto2' not found
-- Could NOT find Doxygen (missing: DOXYGEN_EXECUTABLE)
-- To enable PlantUML support, set PLANTUML_JAR environment variable or pass -DPLANTUML_JAR=<filepath> option to cmake
-- Found PythonInterp: /usr/bin/python2.7 (found suitable version "2.7.11", minimum required is "2.7")
-- Found PythonLibs: /lib/libpython2.7.so (found suitable exact version "2.7.11")
-- Found PythonInterp: /usr/bin/python3 (found suitable version "3.5.1", minimum required is "3.4")
-- Found PythonLibs: /lib/libpython3.5m.so (found suitable exact version "3.5.1")
-- Could NOT find JNI (missing: JAVA_AWT_LIBRARY JAVA_JVM_LIBRARY JAVA_INCLUDE_PATH JAVA_INCLUDE_PATH2 JAVA_AWT_INCLUDE_PATH)
-- Could NOT find Matlab (missing: MATLAB_MEX_SCRIPT MATLAB_INCLUDE_DIRS MATLAB_ROOT_DIR MATLAB_LIBRARIES MATLAB_LIBRARY_DIRS MATLAB_MEXEXT MATLAB_ARCH MATLAB_BIN)
-- VTK is not found. Please set -DVTK_DIR in CMake to VTK build directory, or to VTK install subdirectory with VTKConfig.cmake file
CMake Error at cmake/OpenCVModule.cmake:295 (message):
No extra modules found in folder: /opencv_contrib/modules
Please provide path to 'opencv_contrib/modules' folder.
Call Stack (most recent call first):
modules/CMakeLists.txt:7 (ocv_glob_modules)
-- Module opencv_ts disabled because opencv_highgui dependency can't be resolved!
--
-- General configuration for OpenCV 3.1.0-dev =====================================
-- Version control: 3.1.0-98-g347ffbb
--
-- Platform:
-- Host: Linux 4.1.15-3-ARCH armv7l
-- CMake: 3.4.1
-- CMake generator: Unix Makefiles
-- CMake build tool: /usr/bin/make
-- Configuration: Release
--
-- C/C++:
-- Built as dynamic libs?: YES
-- C++ Compiler: /usr/bin/c++ (ver 5.3.0)
-- C++ flags (Release): -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wno-narrowing -Wno-delete-non-virtual-dtor -fdiagnostics-show-option -pthread -fomit-frame-pointer -ffunction-sections -fvisibility=hidden -fvisibility-inlines-hidden -O3 -DNDEBUG -DNDEBUG
-- C++ flags (Debug): -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wno-narrowing -Wno-delete-non-virtual-dtor -fdiagnostics-show-option -pthread -fomit-frame-pointer -ffunction-sections -fvisibility=hidden -fvisibility-inlines-hidden -g -O0 -DDEBUG -D_DEBUG
-- C Compiler: /usr/bin/cc
-- C flags (Release): -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wno-narrowing -fdiagnostics-show-option -pthread -fomit-frame-pointer -ffunction-sections -fvisibility=hidden -O3 -DNDEBUG -DNDEBUG
-- C flags (Debug): -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wno-narrowing -fdiagnostics-show-option -pthread -fomit-frame-pointer -ffunction-sections -fvisibility=hidden -g -O0 -DDEBUG -D_DEBUG
-- Linker flags (Release):
-- Linker flags (Debug):
-- Precompiled headers: YES
-- Extra dependencies: /lib/libwebp.so /lib/libpng.so /lib/libz.so /lib/libtiff.so /lib/libjasper.so /lib/libjpeg.so /lib/libImath.so /lib/libIlmImf.so /lib/libIex.so /lib/libHalf.so /lib/libIlmThread.so gtk-x11-2.0 gdk-x11-2.0 pangocairo-1.0 atk-1.0 cairo gdk_pixbuf-2.0 gio-2.0 pangoft2-1.0 pango-1.0 fontconfig freetype gthread-2.0 gstvideo-1.0 gstapp-1.0 gstbase-1.0 gstriff-1.0 gstpbutils-1.0 gstreamer-1.0 gobject-2.0 glib-2.0 dc1394 avcodec avformat avutil swscale avresample /lib/libbz2.so dl m pthread rt
-- 3rdparty dependencies:
--
-- OpenCV modules:
-- To be built: core flann imgproc ml objdetect photo video features2d imgcodecs shape videoio calib3d stitching superres videostab python2 python3
-- Disabled: highgui world
-- Disabled by dependency: ts
-- Unavailable: cudaarithm cudabgsegm cudacodec cudafeatures2d cudafilters cudaimgproc cudalegacy cudaobjdetect cudaoptflow cudastereo cudawarping cudev java viz
--
-- GUI:
-- QT: NO
-- GTK+ 2.x: YES (ver 2.24.29)
-- GThread : YES (ver 2.46.2)
-- GtkGlExt: NO
-- OpenGL support: NO
-- VTK support: NO
--
-- Media I/O:
-- ZLib: /lib/libz.so (ver 1.2.8)
-- JPEG: /lib/libjpeg.so (ver )
-- WEBP: /lib/libwebp.so (ver encoder: 0x0209)
-- PNG: /lib/libpng.so (ver 1.6.20)
-- TIFF: /lib/libtiff.so (ver 42 - 4.0.6)
-- JPEG 2000: /lib/libjasper.so (ver 1.900.1)
-- OpenEXR: /lib/libImath.so /lib/libIlmImf.so /lib/libIex.so /lib/libHalf.so /lib/libIlmThread.so (ver 2.2.0)
-- GDAL: NO
--
-- Video I/O:
-- DC1394 1.x: NO
-- DC1394 2.x: YES (ver 2.2.3)
-- FFMPEG: YES
-- codec: YES (ver 56.60.100)
-- format: YES (ver 56.40.101)
-- util: YES (ver 54.31.100)
-- swscale: YES (ver 3.1.101)
-- resample: YES (ver 2.1.0)
-- gentoo-style: YES
-- GStreamer:
-- base: YES (ver 1.6.2)
-- video: YES (ver 1.6.2)
-- app: YES (ver 1.6.2)
-- riff: YES (ver 1.6.2)
-- pbutils: YES (ver 1.6.2)
-- OpenNI: NO
-- OpenNI PrimeSensor Modules: NO
-- OpenNI2: NO
-- PvAPI: NO
-- GigEVisionSDK: NO
-- UniCap: NO
-- UniCap ucil: NO
-- V4L/V4L2: NO/YES
-- XIMEA: NO
-- Xine: NO
-- gPhoto2: NO
--
-- Parallel framework: pthreads
--
-- Other third-party libraries:
-- Use IPP: NO
-- Use VA: NO
-- Use Intel VA-API/OpenCL: NO
-- Use Eigen: YES (ver 3.2.7)
-- Use Cuda: NO
-- Use OpenCL: YES
-- Use custom HAL: NO
--
-- OpenCL: <Dynamic loading of OpenCL library>
-- Include path: /home/counter/opencv/3rdparty/include/opencl/1.2
-- Use AMDFFT: NO
-- Use AMDBLAS: NO
--
-- Python 2:
-- Interpreter: /usr/bin/python2.7 (ver 2.7.11)
-- Libraries: /lib/libpython2.7.so (ver 2.7.11)
-- numpy: /usr/lib/python2.7/site-packages/numpy/core/include (ver 1.10.4)
-- packages path: lib/python2.7/site-packages
--
-- Python 3:
-- Interpreter: /usr/bin/python3 (ver 3.5.1)
-- Libraries: /lib/libpython3.5m.so (ver 3.5.1)
-- numpy: /usr/lib/python3.5/site-packages/numpy/core/include (ver 1.10.4)
-- packages path: lib/python3.5/site-packages
--
-- Python (for build): /usr/bin/python2.7
--
-- Java:
-- ant: NO
-- JNI: NO
-- Java wrappers: NO
-- Java tests: NO
--
-- Matlab: Matlab not found or implicitly disabled
--
-- Documentation:
-- Doxygen: NO
-- PlantUML: NO
--
-- Tests and samples:
-- Tests: NO
-- Performance tests: NO
-- C/C++ Examples: YES
--
-- Install path: /usr/local
--
-- cvconfig.h is in: /home/counter/opencv/build
-- -----------------------------------------------------------------
--
-- Configuring incomplete, errors occurred!
See also "/home/counter/opencv/build/CMakeFiles/CMakeOutput.log".
See also "/home/counter/opencv/build/CMakeFiles/CMakeError.log".
I grep for fatal errors:
less /home/counter/opencv/build/CMakeFiles/CMakeError.log | grep -e "fatal error"
/home/counter/opencv/build/CMakeFiles/CMakeTmp/CheckIncludeFile.c:1:37: fatal error: /usr/include/libpng/png.h: No such file or directory
/home/counter/opencv/build/CMakeFiles/CMakeTmp/CheckIncludeFile.c:1:28: fatal error: linux/videodev.h: No such file or directory
/home/counter/opencv/build/CMakeFiles/CMakeTmp/CheckIncludeFile.c:1:25: fatal error: sys/videoio.h: No such file or directory
/home/counter/opencv/build/CMakeFiles/CMakeTmp/CheckIncludeFile.c:1:29: fatal error: ffmpeg/avformat.h: No such file or directory
/home/counter/opencv/build/CMakeFiles/CMakeTmp/CheckIncludeFile.c:1:28: fatal error: linux/videodev.h: No such file or directory
/home/counter/opencv/build/CMakeFiles/CMakeTmp/CheckIncludeFile.c:1:25: fatal error: sys/videoio.h: No such file or directory
/home/counter/opencv/build/CMakeFiles/CMakeTmp/CheckIncludeFile.c:1:29: fatal error: ffmpeg/avformat.h: No such file or directory
/home/counter/opencv/build/CMakeFiles/CMakeTmp/CheckIncludeFile.c:1:28: fatal error: linux/videodev.h: No such file or directory
/home/counter/opencv/build/CMakeFiles/CMakeTmp/CheckIncludeFile.c:1:25: fatal error: sys/videoio.h: No such file or directory
/home/counter/opencv/build/CMakeFiles/CMakeTmp/CheckIncludeFile.c:1:29: fatal error: ffmpeg/avformat.h: No such file or directory
/home/counter/opencv/build/CMakeFiles/CMakeTmp/CheckIncludeFile.c:1:28: fatal error: linux/videodev.h: No such file or directory
/home/counter/opencv/build/CMakeFiles/CMakeTmp/CheckIncludeFile.c:1:25: fatal error: sys/videoio.h: No such file or directory
/home/counter/opencv/build/CMakeFiles/CMakeTmp/CheckIncludeFile.c:1:29: fatal error: ffmpeg/avformat.h: No such file or directory
/home/counter/opencv/build/CMakeFiles/CMakeTmp/CheckIncludeFile.c:1:28: fatal error: linux/videodev.h: No such file or directory
/home/counter/opencv/build/CMakeFiles/CMakeTmp/CheckIncludeFile.c:1:25: fatal error: sys/videoio.h: No such file or directory
/home/counter/opencv/build/CMakeFiles/CMakeTmp/CheckIncludeFile.c:1:29: fatal error: ffmpeg/avformat.h: No such file or directory
All examples on how to install OpenCV for the Pi do not set any flag that they run on a Pi and I guess I have installed all dependencies, I do not want to create sym links between libraries to make it work.
Edit: I can install a working opencv with yaourt but not opencv-contrib