【昇腾】【玩转Atlas200DK系列】Atlas 200 DK安装python3的hiai库以及opencv
【昇腾】开发板上安装python2的hiai库和opencv库
Matrix是已经支持phthon接口了,但是发现目前python的hiai库并没有自动安装,需要自己安装;
话不多说下面是安装步骤:
步骤1. 开发板联网,如果已联网则跳过该步骤;
否则请参考以下链接配置开发板联网(https://bbs.huaweicloud.com/forum/thread-26546-1-1.html )
接下来需要在开发板上配置arm的源(编辑/etc/apt/sources.list内容替换为如下中科大的源或者清华的源);
中科大源
deb http://mirrors.ustc.edu.cn/ubuntu-ports/ xenial main multiverse restricted universe
deb http://mirrors.ustc.edu.cn/ubuntu-ports/ xenial-backports main multiverse restricted universe
deb http://mirrors.ustc.edu.cn/ubuntu-ports/ xenial-proposed main multiverse restricted universe
deb http://mirrors.ustc.edu.cn/ubuntu-ports/ xenial-security main multiverse restricted universe
deb http://mirrors.ustc.edu.cn/ubuntu-ports/ xenial-updates main multiverse restricted universe
deb-src http://mirrors.ustc.edu.cn/ubuntu-ports/ xenial main multiverse restricted universe
deb-src http://mirrors.ustc.edu.cn/ubuntu-ports/ xenial-backports main multiverse restricted universe
deb-src http://mirrors.ustc.edu.cn/ubuntu-ports/ xenial-proposed main multiverse restricted universe
deb-src http://mirrors.ustc.edu.cn/ubuntu-ports/ xenial-security main multiverse restricted universe
deb-src http://mirrors.ustc.edu.cn/ubuntu-ports/ xenial-updates main multiverse restricted universe
清华源:
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ xenial main multiverse restricted universe
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ xenial-security main multiverse restricted universe
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ xenial-updates main multiverse restricted universe
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ xenial-backports main multiverse restricted universe
deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ xenial main multiverse restricted universe
deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ xenial-security main multiverse restricted universe
deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ xenial-updates main multiverse restricted universe
deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ xenial-backports main multiverse restricted universe
更换源以后注意执行:sudo apt-get update
步骤2. python3 hiai 库安装
安装依赖库
apt-get install python3-setuptools python3-pip python-funcsigs python3-dev build-essential
安装依赖的python库
pip3 install numpy Enum34 future
将附件中的hiai_py3_install.sh拷贝到开发板。脚本下载地址 https://gitee.com/Atlas200DK/sample-pythonClassifyDemo/blob/master/scripts/python3_hiai_install.sh
登录开发板,切换到root用户,执行安装脚本
./hiai_py3_install.sh
6. 命令行执行
python3
import hiai
测试安装是否成功
步骤3. 在开发板上为Python3安装OpenCV
在帖子:https://bbs.huaweicloud.com/forum/thread-28882-1-1.html中介绍了为Python2安装OpenCV的方法,一条apt-get install python-opencv命令即可。但无法找到能够直接这么安装的arm的源,在这里只能给大家介绍源码编译方式为Python3安装OpenCV:
注意:以下命令均在root用户下执行;
1. 安装构建opencv的工具:
apt-get install build-essential -y
apt-get install cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev libv4l-dev -y
2. 下载源码
git clone https://github.com/opencv/opencv.git
3. 在opencv中构建环境
cd opencv
mkdir release
cd release/
cmake -D BUILD_opencv_python3=YES -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=/usr/local -D WITH_LIBV4L=ON -D OPENCV_EXTRA_MODULES=../../opencv_contrib/modules -D PYTHON3_LIBRARIES=/usr/lib/arm-linux-gnueabihf/libpython3.5m.so -D PYTHON3_NUMPY_INCLUDE_DIRS=/usr/local/lib/python3.5/dist-packages/numpy/core/include/ ..
4. 编译
make -j8
5. 安装并更新动态库
make install
ldconfig
- 点赞
- 收藏
- 关注作者
评论(0)