输入指令:
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/lib
cd pkgconfig #如果没有这个文件夹就创建一个,指令:sudo mkdir pkgconfig
sudo 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
另附安装opecv的方法可参考博主:https://blog.csdn.net/public669/article/details/99044895