0

我正在使用 Raspberry Pi 3 在 Raspbian 中安装 opencv,遵循代码部分中提到的 Adrian Rosebrock 博士给出的教程。

 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/ 

根据教程,我应该在这个 list 命令之后找到 opencv + python 发现,但我在 site-packages 或 dist 包中都没有找到它。此外,当我在我的程序中使用 import cv 或 cv2 命令时,它说没有找到此名称的模块,表明未安装 opencv。考虑到上述代码的所有步骤都没有任何错误执行,为什么会发生这种情况。请指导。

4

0 回答 0