Download and unzip
To learn YOLOv3-darknet, OpenCV3.4.0 needs to be installed.
Official website address: https://opencv.org/releases.html
Download opencv3.4.0 and opencv_contrib compressed package from opencv official website. Unzip the downloaded opencv3.4.0 and opencv_contrib-3.4.0, and put the opencv_contrib-3.4.0 folder into the opencv3.4.0 folder.
Environment configuration
Open the terminal and enter the following command:
sudo apt-get install build-essential
sudo apt-get install cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev
sudo apt-get install python-dev python-numpy libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libjasper-dev libdc1394-22-dev
If the error E: Unable to locate package libjasper-dev appears, execute the following commands in sequence:
sudo add-apt-repository "deb http://security.ubuntu.com/ubuntu xenial-security main"
sudo apt update
sudo apt install libjasper1 libjasper-dev
Additional installation (can be skipped)
Since YOLOv3-darknet needs to display pictures for video detection, the following problems will be encountered:
OpenCV Error: Unspecified error (The function is not implemented. Rebuild the library with Windows, GTK+ 2.x or Carbon support. If you are on Ubuntu or Debian, install libgtk2.0-dev and pkg-config, then re-run cmake or configure script) in cvShowImage, file /io/opencv/modules/highgui/src/window.cpp, line 593
So also install the following two files:
sudo apt-get install libgtk2.0-dev pkg-config
After the installation is successful, run cmake to compile opencv and install
cmake
cd opencv-3.4.0
mkdir build
# 创建编译文件
cd build
# 正常情况下使用如下cmake命令即可
cmake -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=/usr/local ..
# 但是,由于cuda10.0对环境有点不支持,可能需要加上-D BUILD_opencv_cudacodec=OFF
cmake -D CMAKE_BUILD_TYPE=Release -D BUILD_opencv_cudacodec=OFF -D CMAKE_INSTALL_PREFIX=/usr/local ..
cmake compilation:
installation
# 4个线程编译,查看cpu核数量
make -j4
# 安装
sudo make install
Two-step installation:
Configure the opencv compilation environment and add it to the system path
# 打开配置文件,可能是空文件
sudo gedit /etc/ld.so.conf.d/opencv.conf
# 在出现的编辑器中加上如下,保存
/usr/local/lib
# 使配置生效
sudo ldconfig
# 配置bash.bash.rc
sudo gedit /etc/bash.bashrc
# 在最后面添加下面两条路径
PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig
export PKG_CONFIG_PATH
# 保存,使配置生效
source /etc/bash.bashrc
sudo updatedb
test
Enter the opencv/samples/cpp directory, there is a routine that comes with opencv, we compile this routine
cd ../samples/cpp/example_cmake
cmake .
make
./opencv_example
The camera is turned on and opencv3.4.0 can be used normally.
Reference (thanks)
1、https://blog.csdn.net/qq_36059536/article/details/107356389
2、https://blog.csdn.net/qq_38236355/article/details/88864023?utm_medium=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-2.control&depth_1-utm_source=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-2.control
3、https://blog.csdn.net/kevineeo/article/details/83242516?utm_medium=distribute.pc_relevant_t0.none-task-blog-BlogCommendFromMachineLearnPai2-1.control&depth_1-utm_source=distribute.pc_relevant_t0.none-task-blog-BlogCommendFromMachineLearnPai2-1.control