Opencv not being installed in Raspbian Stretch

178 Views Asked by At

I am installing opencv in Raspbian stretch using Raspberry Pi 3, following the tutorial given by Dr. Adrian Rosebrock as mentioned in the code section.

 sudo apt-get update && sudo apt-get upgrade
 sudo apt-get install build-essential cmake pkg-config
 sudo apt-get install libjpeg-dev libtiff5-dev libjasper-dev libpng12- 
 dev
 sudo apt-get install libavcodec-dev libavformat-dev libswscale-dev 
 libv4l-dev
 sudo apt-get install libxvidcore-dev libx264-dev
 sudo apt-get install libgtk2.0-dev libgtk-3-dev 
 sudo apt-get install libatlas-base-dev gfortran
 sudo apt-get install python2.7-dev python3-dev  
 cd ~
 wget -O opencv.zip 
 https://github.com/Itseez/opencv/archive/3.3.0.zip
 unzip opencv.zip
 wget -O opencv_contrib.zip 
 https://github.com/Itseez/opencv_contrib/archive/3.3.0.zip
 unzip opencv_contrib.zip
 wget https://bootstrap.pypa.io/get-pip.py
 sudo python get-pip.py
 sudo python3 get-pip.py
 sudo pip install virtualenv virtualenvwrapper
 sudo rm -rf ~/.cache/pip
 export WORKON_HOME=$HOME/.virtualenvs
 export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3
 source /usr/local/bin/virtualenvwrapper.sh
 echo -e "\n# virtualenv and virtualenvwrapper" >> ~/.profile
 echo "export WORKON_HOME=$HOME/.virtualenvs" >> ~/.profile
 echo "export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3" >> ~/.profile
 echo "source /usr/local/bin/virtualenvwrapper.sh" >> ~/.profile
 mkvirtualenv cv -p python2
 mkvirtualenv cv -p python3
 pip install numpy
 workon cv

 cd ~/opencv-3.3.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.3.0/modules \
        -D BUILD_EXAMPLES=ON ..

 CONF_SWAPSIZE=1024
 sudo /etc/init.d/dphys-swapfile stop
 sudo /etc/init.d/dphys-swapfile start
 make -j4
 sudo make install
 sudo ldconfig
 ls -l /usr/local/lib/python2.7/site-packages/ 

According to the tutorial I should find opencv + python findings after this list command but I am not finding it either in site-packages or in dist packages. Also when I use import cv or cv2 command in my program it says no module of this name found, suggesting that opencv is not installed. Considering that all the steps of the above code were executed without any error why is this happening. Kindly guide.

0

There are 0 best solutions below