「玩转树莓派」树莓派 3B+ 安装 OpenCv

2019-12-09 18:35:37 浏览数 (1)

前言

据说,网上有人安装了 7 个月才在树莓派上把 OpenCv 安装成功,然后我就想挑战以下,能不能在七分钟内搞定。

开始

安装基础组件:

代码语言:javascript复制
sudo apt-get update
sudo apt-get install libjpeg-dev libatlas-base-dev libjpeg-dev libtiff5-dev libpng12-dev libqtgui4 libqt4-test libjasper-dev  

然后:

代码语言:javascript复制
sudo pip3 install opencv-python

一般情况,你是不可能安装成功的,99.999% 会出现以下错误:

代码语言:javascript复制
Collecting opencv-python
  Downloading https://www.piwheels.org/simple/opencv-python/opencv_python-3.4.4.19-cp35-cp35m-linux_armv7l.whl (7.4MB)
    45% |██████████████▍                 | 3.3MB 15kB/s eta 0:04:20
THESE PACKAGES DO NOT MATCH THE HASHES FROM THE REQUIREMENTS FILE. If you have updated the package versions, please update the hashes. Otherwise, examine the package contents carefully; someone may have tampered with them.
    opencv-python from https://www.piwheels.org/simple/opencv-python/opencv_python-3.4.4.19-cp35-cp35m-linux_armv7l.whl#sha256=329d9d9fdd62b93d44a485aeaab4602c6f5b8555ea8bcc7dbcdc62c90cfe2c3f:
        Expected sha256 329d9d9fdd62b93d44a485aeaab4602c6f5b8555ea8bcc7dbcdc62c90cfe2c3f
             Got        869c7994c40b84ac09f244f768db9269d52d3265d376441e8516a47f24711ef2

这可能是由于网速太慢了,没有下载完整的文件,所以不完整的文件的md5和期望的不一样。

我们首先下载 whl 文件到本地:

代码语言:javascript复制
# 浏览器直接访问就可以
https://www.piwheels.org/simple/opencv-python/opencv_python-3.4.4.19-cp35-cp35m-linux_armv7l.whl

然后上传到树莓派,使用以下命令安装:

代码语言:javascript复制
sudo pip3 install opencv_python-3.4.4.19-cp35-cp35m-linux_armv7l.whl

如果出现以下代码,说明安装成功:

代码语言:javascript复制
Processing ./opencv_python-3.4.4.19-cp35-cp35m-linux_armv7l.whl
Requirement already satisfied: numpy>=1.12.1 in /usr/lib/python3/dist-packages (from opencv-python==3.4.4.19)
Installing collected packages: opencv-python
Successfully installed opencv-python-3.4.4.19

小结

不想说话,静静的再等五分钟。

0 人点赞