Ubuntu20.04安装Opencv20.04
参考
https://blog.csdn.net/qq_45915007/article/details/113000097?spm=1001.2101.3001.6650.3&utm_medium=distribute.pc_relevant.none-task-blog-2%7Edefault%7ECTRLIST%7ERate-3.pc_relevant_default&depth_1-utm_source=distribute.pc_relevant.none-task-blog-2%7Edefault%7ECTRLIST%7ERate-3.pc_relevant_default&utm_relevant_index=6
最后尝试环境配置,均失败
验证安装是否完成,执行下面代码:
pkg-config opencv --modversion
报错
Package opencv was not found in the pkg-config search path.
Perhaps you should add the directory containing `opencv.pc'
to the PKG_CONFIG_PATH environment variable
No package 'opencv' found
参考
https://blog.csdn.net/PecoHe/article/details/97476135
是缺失opencv.pc配置信息文件,故解决方法就是添加这个文件然后将其导入到环境变量中,具体操作如下:
首先创建opencv.pc文件:
prefix=/usr/local
exec_prefix=${prefix}
includedir=${prefix}/include
libdir=${exec_prefix}/lib
Name: opencv
Description: The opencv library
Version:4.5.3
Cflags: -I${includedir}/opencv4
Libs: -L${libdir} -lopencv_shape -lopencv_stitching -lopencv_objdetect -lopencv_superres -lopencv_videostab -lopencv_calib3d -lopencv_features2d -lopencv_highgui -lopencv_videoio -lopencv_imgcodecs -lopencv_video -lopencv_photo -lopencv_ml -lopencv_imgproc -lopencv_flann -lopencv_core
~
Version是Opencv版本(我的是4.5.3)
保存退出,然后将文件导入到环境变量:
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
至此opencv.pc就配置好了
再次执行
opencv_version
pkg-config opencv --modversion