Install OpenCv 2.4.10 on Linux Ubuntu 14.04 log

1. Prepare Dependencies
sudo apt-get install build-essential libgtk2.0-dev libjpeg-dev libtiff4-dev libjasper-dev libopenexr-dev cmake python-dev python-numpy python-tk libtbb-dev libeigen3-dev yasm libfaac-dev libopencore-amrnb-dev libopencore-amrwb-dev libtheora-dev libvorbis-dev libxvidcore-dev libx264-dev libqt4-dev libqt4-opengl-dev sphinx-common texlive-latex-extra libv4l-dev libdc1394-22-dev libavcodec-dev libavformat-dev libswscale-dev default-jdk ant libvtk5-qt4-dev

2. Download and Unzip OpenCv 2.4.10

3. Do Cmake on Build directory
mkdir build
cd build
cmake -D WITH_TBB=ON -D BUILD_NEW_PYTHON_SUPPORT=ON -D WITH_V4L=ON \
-D INSTALL_C_EXAMPLES=ON -D INSTALL_PYTHON_EXAMPLES=ON \
-D BUILD_EXAMPLES=ON -D WITH_QT=ON -D WITH_OPENGL=ON \
-D WITH_VTK=ON ..

4. Make
make -j 6 
sudo make install
---------  End Installation

5. Check the installation

cp ../../modules/java/test/.build/res/drawable/lena.jpg .
cd bin
./c-example-facedetect  --cascade="../../data/haarcascades/haarcascade_frontalface_alt.xml" --nested-cascade="../../data/haarcascades/haarcascade_eye.xml" --scale=1.3 /home/peerajak/__Feature__/opencv-2.4.10/build/lena.jpg

The result is shown in Lena.jpg below. 
If your notebook has build in web camera. The below will open up the web cam and apply face detector on your face.
 
./c-example-facedetect  --cascade="../../data/haarcascades/haarcascade_frontalface_alt.xml" --nested-cascade="../../data/haarcascades/haarcascade_eye.xml" --scale=1.3

ความคิดเห็น

  1. For CUDA 7.5 with GTX980-ti

    cmake -D WITH_TBB=ON -D BUILD_NEW_PYTHON_SUPPORT=ON -D WITH_V4L=ON -D INSTALL_C_EXAMPLES=ON -D INSTALL_PYTHON_EXAMPLES=ON -D BUILD_EXAMPLES=ON -D WITH_QT=ON -D WITH_OPENGL=ON -D WITH_VTK=ON -D CUDA_GENERATION=Auto ..

    ตอบลบ
  2. For Cuda 8.0, I found the following error
    /home/peerajak/__Feature__/opencv-2.4.10/modules/gpu/src/graphcuts.cpp:274:146: error: ‘nppiGraphcut8_32f8u’ was not declared in this scope
    static_cast(terminals.step), static_cast(leftTransp.step), sznpp, labels.ptr(), static_cast(labels.step), state) );
    ^
    /home/peerajak/__Feature__/opencv-2.4.10/modules/gpu/src/cuda/safe_call.hpp:84:43: note: in definition of macro ‘nppSafeCall’
    #define nppSafeCall(expr) ___nppSafeCall(expr, __FILE__, __LINE__, CV_Func)
    ^
    make[2]: *** [modules/gpu/CMakeFiles/opencv_gpu.dir/src/graphcuts.cpp.o] Error 1

    Solution:
    1. Download Cuda_8.0 patch bugfix from Nvidia and install it.
    2. open opencv-2.4.10/modules/src/graphcuts.cpp and replace the line
    #if !defined (HAVE_CUDA) || defined (CUDA_DISABLER)
    with
    #if !defined (HAVE_CUDA) || defined (CUDA_DISABLER) || (CUDART_VERSION >= 8000)

    ตอบลบ
  3. Installation of OpenCV 2.4.11 along with CUDA 8.0 (Ubuntu 14.04)
    This is a short blog on how to install OpenCV 2.4.11 along with CUDA 8.0 . Although CUDA can be skipped but I will prefer everyone to install it along with CUDA. This helps in using GPUs along with OpenCV . You can follow CUDA installation from this post(till step 15) .

    The script to install OpenCV is given here. You might get different errors while installing OpenCV along with CUDA. I will mention solution to some of the error I encountered. For people installing OpenCV without CUDA should not face any errors while installation .

    Errors

    1) While running the cmake command , I got "nvcc fatal : Unsupported gpu architecture 'compute_11' "
    error. To deal with such error just add "-D CUDA_GENERATION=Kepler " before '..' and run the cmake once again. This should solve your problems regarding GPU architecture.

    2) I have CUDA 8.0 version installed in my laptop. While running the cmake ,one might get "error: ‘NppiGraphcutState’ has not been declared " error. It took me some time to get the solution for this error. The Problem here is that Opencv doesn't know about CUDA 8.0 and so one has to mention it explicitly . Moreover graphcuts is not directly supported by CUDA 8.0 anymore.

    a) $ gedit /home//opencv-2.4.11/modules/cudalegacy/src/graphcuts.cpp
    Now search for this specific line .
    #if !defined (HAVE_CUDA) || defined (CUDA_DISABLER)




    Replace the line with this line .
    #if !defined (HAVE_CUDA) || defined (CUDA_DISABLER) || (CUDART_VERSION >= 8000)




    b) Rerun the cmake statement and you shouldn't be getting the same error .

    I faced these errors and thus provided a solution to it. In case of any other errors please refer to this link .

    Other Links

    dynamicGuy
    cuda8.0 solution
    Graphcut

    ตอบลบ

แสดงความคิดเห็น

บทความที่ได้รับความนิยม