安装opencv4.4.0版本问题

输入指令:

pkg-config opencv --modversion

查看不了自己opencv的版本号,出现下面情况:

berzelius12@lcr-bzl:~/opencv-4.5.2/build$ 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

解决方法:

安装完成后,手动创建opencv.pc:

cd /usr/local/libcd pkgconfig  #如果没有这个文件夹就创建一个,指令:sudo mkdir pkgconfigsudo gedit opencv.pc

 然后添加文本:

prefix=/usr/local
exec_prefix=${prefix}
includedir=/usr/local/include
libdir=/usr/local/lib
 
Name: OpenCV
Description: Open Source Computer Vision Library
Version: 4.4.0
Libs: -L${exec_prefix}/lib -lopencv_stitching -lopencv_superres -lopencv_videostab -lopencv_aruco -lopencv_bgsegm -lopencv_bioinspired -lopencv_ccalib -lopencv_dnn_objdetect -lopencv_dpm -lopencv_face -lopencv_photo -lopencv_freetype -lopencv_fuzzy -lopencv_hdf -lopencv_hfs -lopencv_img_hash -lopencv_line_descriptor -lopencv_optflow -lopencv_reg -lopencv_rgbd -lopencv_saliency -lopencv_stereo -lopencv_structured_light -lopencv_phase_unwrapping -lopencv_surface_matching -lopencv_tracking -lopencv_datasets -lopencv_text -lopencv_dnn -lopencv_plot -lopencv_xfeatures2d -lopencv_shape -lopencv_video -lopencv_ml -lopencv_ximgproc -lopencv_calib3d -lopencv_features2d -lopencv_highgui -lopencv_videoio -lopencv_flann -lopencv_xobjdetect -lopencv_imgcodecs -lopencv_objdetect -lopencv_xphoto -lopencv_imgproc -lopencv_core
Libs.private: -ldl -lm -lpthread -lrt
Cflags: -I${includedir}

更改环境变量,输入命令:

sudo gedit /etc/bash.bashrc

打开之后,在文件最后面添加以下内容:

export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH

 保存退出,opencv基本上就安装完成了。再通过 pkg-config 查看 opencv 版本:

pkg-config --modversion opencv
berzelius12@lcr-bzl:/usr/local/lib/pkgconfig$ pkg-config opencv --modversion
4.4.0

成功解决。参考大佬博主https://blog.csdn.net/qianbin3200896/article/details/107894029?utm_medium=distribute.pc_relevant.none-task-blog-baidujs_baidulandingword-10&spm=1001.2101.3001.4242

另附安装opecv的方法可参考博主:https://blog.csdn.net/public669/article/details/99044895

上一篇:Go语言工程结构详述


下一篇:检查RPM包是否安装的Shell脚本