本文主要是介绍14、zedboard 7020 编译Opencv3.4+Opencv_contrib3.4+DeepSort(软核),希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
基本问题描述:因为希望使用opencv 附加库的DNN 模块,搞一下深度学习的内容,因为上一篇博客已经自己制作了一个debain系统在zynq7020上,因此在该系统上编译opencv3.4 上,编译过程如下:
1、安装附加库
sudo apt-get install build-essential cmake git pkg-config
sudo apt-get install libjpeg8-dev
sudo apt-get install libtiff5-dev
sudo apt-get install libjasper-dev
sudo apt-get install libpng12-dev
sudo apt-get install libavcodec-dev libavformat-dev libswscale-dev libv4l-dev
sudo apt-get install libgtk2.0-dev
sudo apt-get install python-dev python3-dev
sudo apt-get install python-numpy python3-numpy
2、下载opencv3.4 的源码和附件库 (直接git下载即可)
因为git 之后的opencv 仍然需要安装下载一些东西,因此我提供一份已经下载之后,存在错误修改过之后的源码
opencv3.4 链接:https://pan.baidu.com/s/18rR4GGDvBEFCGpXRdsNmKA 密码:n0x4
opencv_contribu3.4 链接:https://pan.baidu.com/s/1cDv7QenVuj5H9n8kRJq0CQ 密码:92r3
3、 进入目录进行编译 编译产生 python3 的so文件
cmake -D BUILD_opencv_python3=YES -D BUILD_opencv_python2=NO -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D INSTALL_C_EXAMPLES=ON -D INSTALL_PYTHON_EXAMPLES=ON -D BUILD_EXAMPLES=ON -D WITH_LIBV4L=ON -D WITH_GTK=ON -D PYTHON3_EXECUTABLE=/usr/bin/python3 -D PYTHON_INCLUDE_DIR=/usr/include/python3.5 -D PYTHON_LIBARARY=/usr/lib/python3.5/config-3.5m-arm-linux-gnueabihf/libpython3.5m.so -D PYTHON3_NUMPY_INCLUDE_DIRS=/usr/local/lib/python3.5/dist-packages/numpy/core/include -D ENABLE_PRECOMPILED_HEADERS=ON -D OPENCV_ENABLE_NONFREE=ON -D OPENCV_EXTRA_MODULES_PATH=../../opencv_contrib-3.4.4/modules/ ..
4、编译成功
make
sudo make install
5、成功的显示
debain@debian:~/opencv-3.4.4/build/lib/python3$ ls
cv2.cpython-35m-arm-linux-gnueabihf.so
debain@debian:~/opencv-3.4.4/build/lib/python3$
6、移动文件
debain@debian:~/opencv-3.4.4/build/lib/python3$ sudo cp cv2.cpython-35m-arm-linux-gnueabihf.so /usr/local/lib/python3.5/dist-packages/
debain@debian:~/opencv-3.4.4/build/lib/python3$ sudo ldconfig
debain@debian:~/opencv-3.4.4/build/lib/python3$ python3
Python 3.5.3 (default, Sep 27 2018, 17:25:39)
[GCC 6.3.0 20170516] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
>>>
如果你要使用python2 也可以调用opencv cmake命令改成这个即可
cmake -D BUILD_opencv_python3=NO -D BUILD_opencv_python2=YES -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D INSTALL_C_EXAMPLES=ON -D INSTALL_PYTHON_EXAMPLES=ON -D BUILD_EXAMPLES=ON -D WITH_LIBV4L=ON -D WITH_GTK=ON -D PYTHON3_EXECUTABLE=/usr/bin/python2 -D PYTHON_INCLUDE_DIR=/usr/include/python2.7 -D PYTHON_LIBARARY=/usr/lib/python2.7/config-arm-linux-gnueabihf/libpython2.7m.so -D PYTHON_NUMPY_INCLUDE_DIRS=/usr/local/lib/python2.7/dist-packages/numpy/core/include -D ENABLE_PRECOMPILED_HEADERS=ON -D OPENCV_ENABLE_NONFREE=ON -D OPENCV_EXTRA_MODULES_PATH=../../opencv_contrib-3.4.4/modules/ ..
然后就可以调用c++ 的deepsort跟踪算法:https://github.com/sxj731533730/DeepSort
这篇关于14、zedboard 7020 编译Opencv3.4+Opencv_contrib3.4+DeepSort(软核)的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!