I have installed OpenCV succesfully with most of the options in Ubuntu as below
1. Install the required packages
apt-get install build-essential doxygen imagemagick python-pip python-dev cmake ant default-jdk libgphoto2-dev zlibc libdc1394-22-dev libgstreamer1.0-dev gstreamer1.0-plugins-base gstreamer1.0-tools gstreamer0.10 libv4l2rds0 jasper libjasper-dev libjasper1 libjasperreports-java
libtiff-tools libtiff-opengl libtiff5 libtiff5-dev libtiffxx5 python-libtiff libjpeg8-dev liblapack3 libjpeg-turbo8-dev liblzma-dev python-numpy libjpeg-dev libblas3 python-imaging libpng-dev libgtk-3-dev gstreamer-tools gstreamer1.0 libv4l-dev libavcodec-dev libavformat-dev libswscale-dev
libavresample-dev libtbb-dev python3-dev python3-numpy qt-sdk python3-pip yasm libvtk5-dev vtk-examples tcl-vtk python-vtk libvtk-java libvtk5.8-qt4 glogg libgtkglext1-dev libavformat-extra-54 dctrl-tools libilmbase-dev libopenexr-dev libptexenc1 luatex libtheora-dev libvorbis-dev libxvidcore-dev libx264-dev libopencore-amrnb-dev libopencore-amrwb-dev libxine2-dev zlib1g-dev libwebp-dev libgdal-dev libeigen3-dev python-tk python3-tk qt5-default libvtk6-dev libavformat-extra-54 libxkbcommon-x11-dev libvncserver0 x11vnc-data x11vnc
2. Update the packages and upgrade the cmake to >= 2.8.12.2
apt-get update
apt-get upgrade cmake
3. Install Python package
pip install numpy
pip install -U pip setuptools
4. Fix the issues before installing opencv
a. Issue:
Could NOT find PythonLibs (missing: PYTHON_INCLUDE_DIRS)
(found suitable exact version "2.7.6")
Solution:
Some last version of Ubuntu installs Python 3.4 by default and
the CMake version from Ubuntu (2.8) only searches up to Python 3.3.
Try to add set(Python_ADDITIONAL_VERSIONS 3.4) before the
find_package statement.
/apps/build/opencv-3.1.0/CMakeLists.txt
Remember to clean CMakeCache.txt too.
b. Issue:
Looking for linux/videodev.h - not found
Solution:
sudo apt-get install libv4l-dev
cd /usr/include/linux
sudo ln -s ../libv4l1-videodev.h videodev.h
c. Issue:
Looking for ffmpeg/avformat.h - not found
Solution:
cd /usr/include/
sudo mkdir ffmpeg
sudo cp /usr/include/libavcodec/* /usr/include/ffmpeg/
sudo cp /usr/include/libavformat/* /usr/include/ffmpeg/
sudo cp /usr/include/libswscale/* /usr/include/ffmpeg/
5. Install Tesseract if you want to configure with OpenCV
6. Download the OpenCV source
curl -L -o opencv-3.1.0.tar.gz https://github.com/Itseez/opencv/archive/3.1.0.tar.gz
tar -xzf opencv-3.1.0.tar.gz
Also download opencv_contrib
7. Configure OpenCV
cd opencv-3.1.0
mkdir release
cd release
cmake -D CMAKE_BUILD_TYPE=Release -D BUILD_EXAMPLES=ON -D CMAKE_INSTALL_PREFIX=/usr/local -D INSTALL_C_EXAMPLES=ON -DPLANTUML_JAR=<Full_Path>/plantuml.jar -DOPENCV_EXTRA_MODULES_PATH=<Full_Path>/opencv_contrib/modules -D WITH_TBB=ON -DWITH_QT=ON -DWITH_OPENGL=ON -DFORCE_VTK=ON -DWITH_GDAL=ON -DWITH_XINE=ON ..
make -j7
make install
sudo ldconfig
8. Test installation
cd <OpenCv_Src>/<Build_Dir>/bincp <OpenCv_Src>/samples/java/clojure/simple-sample/resources/images/lena.png .
cp <OpenCv_Src>/samples/data/lena.jpg .
./opencv_test_core
If successful you will see as below: