OpenCV 4.x的夏季更新已发布 :晴天:
SIFT(尺度不变特征变换)算法已移至主存储库(SIFT的专利已过期)
DNN模块:
改进的图层/激活/支持更多模型:
G-API模块:
在OpenCV后端引入了用于状态内核的新API :GAPI_OCV_KERNEL_ST。有状态内核在各个图执行(在标准中更多)或流的视频帧(在流模式下)中保留其状态。
在G-API推出更多面向视频的操作:goodFeaturesToTrack,buildOpticalFlowPyramid,calcOpicalFlowPyrLK。
添加了更多的图像处理内核:Laplacian和双边过滤器。
修复了G-API的OpenCL后端中的潜在崩溃。
beizhu https://blog.csdn.net/dongkaiwen48/article/details/97765096
1、首先移除nx中已经默认的opencv。
sudo apt-get purge libopencv*
sudo apt autoremove
sudo apt-get update
2、检查已安装组件
https://blog.csdn.net/beckhans/article/details/89138876
有一步是10.2
export CUDA_HOME=/usr/local/cuda-10.2
export LD_LIBRARY_PATH=/usr/local/cuda-10.2/lib64:$LD_LIBRARY_PATH
export PATH=/usr/local/cuda-10.2/bin:$PATH
3、依赖库
Ubuntu使用apt-get下载速度慢的解决方法(换源):https://blog.csdn.net/qq_21095573/article/details/99736630
Package has no installation candidate解决方法
*我试着换源:出现了一堆bug,又换回去了,慎重使用,注意备份。
正文:
sudo apt-get install -y build-essential checkinstall cmake pkg-config yasm git gfortran
# 添加源,防止可能会出现的找不到所需安装的库的情况
sudo add-apt-repository -y "deb http://security.ubuntu.com/ubuntu xenial-security main"
sudo apt-get update
sudo apt-get install -y libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev
sudo apt-get install -y libjpeg8-dev libjasper-dev libpng12-dev libtiff5-dev libavcodec-dev libavformat-dev libswscale-dev libdc1394-22-dev libxine2-dev libv4l-dev
sudo apt-get install -y libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev libgtk2.0-dev libtbb-dev libatlas-base-dev libfaac-dev libmp3lame-dev libtheora-dev libvorbis-dev libxvidcore-dev libopencore-amrnb-dev libopencore-amrwb-dev x264 v4l-utils
问题:bash: add-apt-repository: command not found 解决:https://www.jianshu.com/p/986efb4025e8
如果需要python3支持则需要安装下面两个库:
sudo apt install python3-dev python3-numpy
可以选择安装一些可选的库:
sudo apt-get install python-dev python-numpy libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libjasper-dev libdc1394-22-dev
4、下载opencv-4.4.0压缩包
从这里下载的:https://download.csdn.net/download/ciqujinnian_/12660208?utm_source=bbsseo
不然太慢了。
opencv-4.4.0.zip
opencv_contrib-4.4.0.zip
在nx中解压
5、
cd opencv-4.4.0
make build
cd build
执行cmake
cmake \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=/usr/local \
-DOPENCV_ENABLE_NONFREE=1 \
-DBUILD_opencv_python2=1 \
-DBUILD_opencv_python3=1 \
-DWITH_FFMPEG=1 \
-DCUDA_TOOLKIT_ROOT_DIR=/usr/local/cuda-10.2 \
-DCUDA_ARCH_BIN=7.2 \
-DCUDA_ARCH_PTX=7.2 \
-DWITH_CUDA=1 \
-DENABLE_FAST_MATH=1 \
-DCUDA_FAST_MATH=1 \
-DWITH_CUBLAS=1 \
-DOPENCV_GENERATE_PKGCONFIG=1 \
-DOPENCV_EXTRA_MODULES_PATH=../opencv_contrib-4.4.0/modules \
..
注意:
opencv_contrib-4.4.0是放在opencv-4.4.0中,注意路径
使用cuda,-DWITH_CUDA=1
cmake的配置情况可以参考[OpenCV官方文档]:
https://docs.opencv.org/3.2.0/d6/d15/tutorial_building_tegra_cuda.html
6、make
执行make -j12
,
说明:make命令后面跟着线程数,12表示这个命令使用12线路去执行
不过关键线程数不能超过电脑cpu的线程数
cat /proc/stat | grep cpu[0-9] -c
查看线程数
安装OpenCV时提示缺少boostdesc_bgm.i文件的问题解决方案
fatal error: features2d/test/test_detectors_regression.impl.hpp: 没有那个文件或目录
将opencv-4.2.0/modules/features2d/test/
下的文件
test_descriptors_invariance.impl.hpp
test_descriptors_regression.impl.hpp
test_detectors_invariance.impl.hpp
test_detectors_regression.impl.hpp
test_invariance_utils.hpp
拷贝到opencv_contrib-4.2.0/modules/xfeatures2d/test/
下
将opencv_contrib-4.2.0/modules/xfeatures2d/test/test_features2d.cpp
文件里
#include "features2d/test/test_detectors_regression.impl.hpp"
#include "features2d/test/test_descriptors_regression.impl.hpp"
改为
#include "test_detectors_regression.impl.hpp"
#include "test_descriptors_regression.impl.hpp"
将opencv_contrib-4.2.0/modules/xfeatures2d/test/test_rotation_and_scale_invariance.cpp
文件里
#include "features2d/test/test_detectors_invariance.impl.hpp"
#include "features2d/test/test_descriptors_invariance.impl.hpp"
改为
#include "test_detectors_invariance.impl.hpp"
#include "test_descriptors_invariance.impl.hpp"
完成后sudo make install
2 卸载(OpenCV3.1.0为例)
2.1 卸载命令(编译目录)
cd opencv-3.1.0/release/
sudo make uninstall
cd ..
sudo rm -r release
sudo rm -r /usr/local/include/opencv2 /usr/local/include/opencv /usr/include/opencv /usr/include/opencv2 /usr/local/share/opencv /usr/local/share/OpenCV /usr/share/opencv /usr/share/OpenCV /usr/local/bin/opencv* /usr/local/lib/libopencv*
2.2 卸载其它
sudo apt-get –purge remove opencv-doc opencv-data python-opencv
查看opencv版本
python3
import cv2
cv2.__version__
若不成功,配置环境变量
1)安装成功后还需要设置opencv的环境变量。打开文件:
sudo gedit /etc/ld.so.conf.d/opencv.conf
2)将以下内容添加到最后:
/usr/local/opencv4/lib
- 接下来配置库:
sudo ldconfig
- 更改环境变量:
sudo gedit /etc/bash.bashrc
- 在文件后添加:
PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/opencv4/lib/pkgconfig
export PKG_CONFIG_PATH
- 保存退出,在运行下面的例程之前,需要重新开启终端来使配置生效。
***东拼西凑,概不负责,只为自己记录查看。
网友评论