1.上Opencv官网下载自己对应的版本

Opencv网站:https://opencv.org/releases/

2.查看已安装的Opencv版本

查看已安装opencv的版本

pkg-config opencv --modversion

在这里插入图片描述

3.安装新的Opencv(以4.5.1为例)

建立opencv安装文件夹

cd  /usr/local/
sudo mkdir opencv4.5.1

下载解压后
安装路径设置:CMAKE_INSTALL_PREFIX=/usr/local/opencv4.5.1

mkdir build
cd build
cmake 
cmake -D CMAKE_BUILD_TYPE=Release -D OPENCV_GENERATE_PKGCONFIG=ON -D CMAKE_INSTALL_PREFIX=/usr/local/opencv4.5.1 ..
make -j4
sudo make install

成功图示
在这里插入图片描述

4.多版本OpenCV切换(第一种)

1、安装成功后还需要设置opencv的环境变量。打开文件:

sudo gedit /etc/ld.so.conf.d/opencv.conf

2、将opencv3.4.5库文件的路径添加到环境变量中,将以下内容添加到最后::

/usr/local/opencv4.5.1/lib

3、接下来配置库:

sudo ldconfig

4、更改环境变量:

sudo gedit /etc/bash.bashrc

5、在文件后添加:

#opencv4.5.1版本切换
export PKG_CONFIG_PATH=${PKG_CONFIG_PATH}:/usr/local/opencv4.5.1/lib/pkgconfig
export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/usr/local/opencv4.5.1/lib
source ~/.bashrc 

6、再次查询Opencv版本

#终端输入以下两命令,显示正常则安装成功
pkg-config --modversion opencv4 #查看版本号
pkg-config --libs opencv4 #查看libs库

如果输出4.5.1,就表明配置成功。
在这里插入图片描述

如果想使用之前的版本,在~/.bashrc中注释掉增加的内容,然后source ~/.bashrc即可。

5.多版本OpenCV切换(第二种)(推荐)

1、打开~/.bashrc

gedit ~/.bashrc

2、添加以下内容

#opencv4.5.1版本切换
export PKG_CONFIG_PATH=/usr/local/opencv4.5.1/lib/pkgconfig
export LD_LIBRARY_PATH=/usr/local/opencv4.5.1/lib

3、更新~/.bashrc

 source ~/.bashrc

4、再次查询Opencv版本

#终端输入以下两命令,显示正常则安装成功
pkg-config --modversion opencv4 #查看版本号
pkg-config --libs opencv4 #查看libs库

如果输出4.5.1,就表明配置成功。
如果想使用之前的版本,在~/.bashrc中注释掉增加的内容,然后source ~/.bashrc即可。
在这里插入图片描述
在这里插入图片描述

GitHub 加速计划 / opencv31 / opencv
216
19
下载
OpenCV: 开源计算机视觉库
最近提交(Master分支:6 天前 )
5b1d3255 build: fix OpenBLAS cmake search 2 天前
a7943cef features2d: performance optimization of detect function on Windows-ARM64 #27776 ### Pull Request Readiness Checklist See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request - [x] I agree to contribute to the project under Apache 2 License. - [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV - [x] The PR is proposed to the proper branch - This PR improves the performance of the detect function on Windows ARM64 targets. - Added the defined(_M_ARM64) macro in agast.cpp and agast_score.cpp files, aligning ARM64 behavior with how x64 selects internal functions for computation. - As a result, ARM64 now executes the same internal functions as x64 where applicable, leading to measurable performance improvements in detect function. - This changes is limited to Windows ARM64 and does not affect other architectures **Performance impact:** - Detect function shows improved runtime on ARM64 targets due to reuse of existing efficient computation paths. <img width="1419" height="408" alt="image" src="https://github.com/user-attachments/assets/feab411a-d256-4bff-bec2-22b2583f63d1" /> 2 天前
Logo

旨在为数千万中国开发者提供一个无缝且高效的云端环境,以支持学习、使用和贡献开源项目。

更多推荐