Raspbian_For_OrangePi_PC安装opencv
2017-12-10 本文已影响39人
奋斗_登
本文参考文章:https://www.pyimagesearch.com/2015/07/20/install-opencv-3-0-and-python-3-4-on-ubuntu/
1、升级python到最新版本3.6.3
执行以下命令行更新系统软件源
sudo apt-get update && sudo apt-get upgrade -y
下载python3.6.3源码
https://www.python.org/ftp/python/3.6.3/Python-3.6.3.tar.xz
tar -xvf Python-3.6.3.tar.xz
cd Python-3.6.3
./configure --enable-shared #注意一下一定要有这一步
make -j4 #这一步时间比较长
sudo make install
安装完成后执行以下命令
cp libpython3.6m.so.1.0 /usr/lib
pip3 install --upgrade pip
sudo pip3 install numpy #opencv所需要的基础计算库,安装时间较长
安装完成后重新启动系统
reboot
2、安装opencv3.0.0
下载源码
cd /home
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
注意看路径是否对得上
cmake -D CMAKE_BUILD_TYPE=Release \
-D CMAKE_INSTALL_PREFIX=/usr/local \
-D INSTALL_C_EXAMPLES=OFF \
-D INSTALL_PYTHON_EXAMPLES=OFF \
-D OPENCV_EXTRA_MODULES_PATH==/home/opencv_contrib-3.0.0/modules \
-D BUILD_EXAMPLES=OFF \
PYTHON3_EXECUTABLE=/usr/local/bin/python3 \
PYTHON3_INCLUDE_DIR=/usr/local/include/python3.6m \
PYTHON3_LIBRARY=/usr/local/lib/libpython3.6m.so \
PYTHON3_PACKAGES_PATH=/usr/local/lib/python3.6/site-packages \
PYTHON3_NUMPY_INCLUDE_DIRS=/usr/local/lib/python3.6/site-packages/numpy/core/include ..
之后开始编译
make -j4 #这个过程大概1-2小时
sudo make install
make 之后看到如下信息说明成功了
3、检查是否成功
python3
import cv2
cv2.__version__
显示如下信息说明opencv3安装成功了