赞
踩
以下两个文件是20211223从github下载的,网络好的可从github下载
opencv4下载
opencv_contrib-4.x下载
由于国内网络限制,还需要下载所需额外文件
包括了
ippicv_2019_lnx_intel64_general_20180723.tgz
face_landmark_model.dat
boostdesc_bgm.i系列
vgg_generated_48.i系列
1.将解压后 boostdesc_bgm.i,vgg_generated_48.i等opencv4 文件夹中的文件拷贝到opencv_contrib-4.x/modules/xfeatures2d/src目录中
2.将ippicv_2019_lnx_intel64_general_20180723.tgz 和face_landmark_model.dat 放到某个目录/xxx/download/中;打开opencv-4.x/3rdparty/ippicv/ippicv.cmake,修改https://raw.githubusercontent.com/opencv/opencv_3rdparty/${IPPICV_COMMIT}/ippicv/
为file:///xxx/download/
;打开opencv_contrib-4.x/modules/face/CMakeLists.txt,修改https://raw.githubusercontent.com/opencv/opencv_3rdparty/${__commit_hash}/
为file:///xxx/download/
3.安装依赖
sudo apt-get update
sudo apt-get upgrade
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
sudo apt-get install libavcodec-dev libavformat-dev libswscale-dev libv4l-dev liblapacke-dev
sudo apt-get install libxvidcore-dev libx264-dev
sudo apt-get install libatlas-base-dev gfortran
sudo apt-get install ffmpeg
可能出现libjasper-dev无法安装的问题,
如下操作解决:
sudo add-apt-repository "deb http://security.ubuntu.com/ubuntu xenial-security main"
sudo apt update
sudo apt install libjasper1 libjasper-dev
4.安装cmake-gui
sudo apt-get install cmake-gui
有需要省级cmake的可以升个级(升级最好不要卸载,直接覆盖升级) 链接
5.配置cmake-gui
在opencv-4.x中新建build文件夹
配置好文件夹路径
这里没有编译wechat_qrcode模块(需要下载额外文件),取消了这个的勾选
配置扩展模块路径
配置好后点击 Configure
6.转到build文件夹内,
cd opencv-4.x/build
sudo make -j8
sudo make install
默认安装到了/usr/local,可在cmake-gui中更改
7.配置 添加环境变量
sudo gedit /etc/ld.so.conf.d/opencv.conf
添加如下内容,并保存:/usr/local/lib
配置库sudo ldconfig
sudo gedit /etc/bash.bashrc
在末尾添加如下内容
PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig
export PKG_CONFIG_PATH
再更新一下
source bash.bashrc
8.创建opencv4.pc
sudo gedit /usr/local/lib/pkgconfig/opencv4.pc
添加如下内容
# Package Information for pkg-config
prefix=/usr/local
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
includedir_old=${prefix}/include/opencv4/opencv
includedir_new=${prefix}/include/opencv4
Name: OpenCV
Description: Open Source Computer Vision Library
Version: 4.2.0
Libs: -L${exec_prefix}/lib -lopencv_gapi -lopencv_stitching -lopencv_aruco -lopencv_bgsegm -lopencv_bioinspired -lopencv_ccalib -lopencv_dnn_objdetect -lopencv_dpm -lopencv_face -lopencv_freetype -lopencv_fuzzy -lopencv_hfs -lopencv_img_hash -lopencv_line_descriptor -lopencv_quality -lopencv_reg -lopencv_rgbd -lopencv_saliency -lopencv_stereo -lopencv_structured_light -lopencv_phase_unwrapping -lopencv_superres -lopencv_optflow -lopencv_surface_matching -lopencv_tracking -lopencv_datasets -lopencv_text -lopencv_dnn -lopencv_plot -lopencv_videostab -lopencv_video -lopencv_xfeatures2d -lopencv_shape -lopencv_ml -lopencv_ximgproc -lopencv_xobjdetect -lopencv_objdetect -lopencv_calib3d -lopencv_features2d -lopencv_highgui -lopencv_videoio -lopencv_imgcodecs -lopencv_flann -lopencv_xphoto -lopencv_photo -lopencv_imgproc -lopencv_core
Libs.private: -ldl -lm -lpthread -lrt
Cflags: -I${includedir_old} -I${includedir_new}
pkg测试
pkg-config --modversion opencv4
pkg-config --cflags --libs opencv4
参考链接:
https://blog.csdn.net/weixin_41053564/article/details/81254410
https://blog.csdn.net/weixin_40854506/article/details/115289098
https://blog.csdn.net/zzyczzyc/article/details/87954858
https://blog.csdn.net/lwqldsyzx/article/details/105722488
https://blog.csdn.net/weixin_49353816/article/details/113785090
https://blog.csdn.net/wangxubo1988/article/details/114300683
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。