Search code examples
opencvcmakeraspberry-pi3

Install opencv on Raspberry Pi Raspbian


I am trying to install openCV in my RaspberryPi 3 running Raspbian Jessie OS. I am following this tutorial: http://pklab.net/index.php?lang=EN&id=392

After doing:

sudo apt-get update
sudo apt-get upgrade

Things look fine. But when I try to install cmake to build my opencv libraries, I get the following error after entering the following command:

Command entered:

sudo apt-get install build-essential cmake cmake-curses-gui pkg-config

Result:

The following packages have unmet dependencies:
 cmake : Depends: libjsoncpp0 but it is not installable
 cmake-curses-gui : Depends: libjsoncpp0 but it is not installable
E: Unable to correct problems, you have held broken packages.

I can't seem to figure out what is going wrong. I tried to manually install cmake using wget from the mirror on the cmake website and still the same error comes up. Any help is appreciated!


Solution

  • installing open cv is very easy just do this.

    sudo apt-get update
    
    sudo apt-get install -y build-essential git cmake pkg-config \
        libjpeg-dev libtiff5-dev libjasper-dev libpng12-dev \
        libavcodec-dev libavformat-dev libswscale-dev libv4l-dev \
        libxvidcore-dev libx264-dev libgtk2.0-dev \
        libatlas-base-dev gfortran \
        python2.7-dev python3-dev
    

    and then

    cd ~
    wget -O opencv.zip https://github.com/Itseez/opencv/archive/3.0.0.zip
    unzip opencv.zip
    wget -O opencv_contrib.zip 
    https://github.com/Itseez/opencv_contrib/archive/3.0.0.zip
    unzip opencv_contrib.zip
    cd opencv-3.0.0/
    mkdir build
    cd build
    cmake -D CMAKE_BUILD_TYPE=RELEASE \
          -D CMAKE_INSTALL_PREFIX=/usr/local \
          -D INSTALL_C_EXAMPLES=ON \
          -D INSTALL_PYTHON_EXAMPLES=ON \
          -D OPENCV_EXTRA_MODULES_PATH=~/opencv_contrib-3.0.0/modules \
          -D BUILD_EXAMPLES=ON ..
    
    make -j4
    make clean
    make
    sudo make install
    sudo ldconfig
    

    This will take a few hours.

    Extract features with OpenCV Download the Script and sample image with cd ~ wget https://raw.githubusercontent.com/JoBergs/RaspiContent/master/OpenCV_demo/opencv_face_features.py \ https://raw.githubusercontent.com/JoBergs/RaspiContent/master/OpenCV_demo/poi_1.jpg

    Running the Script requires the Raspbian Desktop. If you haven’t already booted into the Desktop,

    open the terminal and

    cd ~
    python opencv_face_features.py poi_1.jpg