如果需要卸载之前版本make uninstallcd ..rm -rf buildrm -rf /usr/local/include/opencv2 /usr/local/include/opencv /usr/include/opencv /usr/include/opencv2 /usr/local/share/opencv /usr/local/share/Open...
如果需要卸载之前版本
make uninstall cd .. rm -rf build rm -rf /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*
unzip opencv-3.4.0.zip
step0 依赖项
$ sudo apt-get install cmake libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev $ sudo apt-get install libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff5-dev libdc1394-22-dev # 处理图像所需的包 $ sudo apt-get install libavcodec-dev libavformat-dev libswscale-dev libv4l-dev liblapacke-dev $ sudo apt-get install libxvidcore-dev libx264-dev # 处理视频所需的包 $ sudo apt-get install libatlas-base-dev gfortran # 优化opencv功能 $ sudo apt-get install ffmpeg
step1 编译
mkdir build cd build cmake -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=/usr/local .. make
step2 安装
make install
step3 配置OpenCV环境
还需要为程序指定openvc的头文件位置,这里使用pkg-config命令来完成。
1、进入/etc/profile配置文件,在文件末尾追加添加以下命令:
export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig
添加完之后使用命令行更新配置文件
source profile
2、查看版本号,验证是否安装成功
pkg-config --modversion opencv
测试程序 test.cpp
1 #include<opencv2/opencv.hpp> 2 3 using namespace cv; 4 5 int main() 6 { 7 Mat src; 8 src = imread("1.jpg"); 9 imshow("img_text",src); 10 waitKey(6000); 11 return 0; 12 }
编写一个CMakeLists.txt,内容如下:
1 cmake_minimum_required(VERSION 2.8) 2 project( test ) 3 find_package( OpenCV REQUIRED ) 4 add_executable( test test.cpp ) 5 target_link_libraries( test ${OpenCV_LIBS} )
沃梦达教程
本文标题为:Ubuntu 配置OpenCV C++
基础教程推荐
猜你喜欢
- C利用语言实现数据结构之队列 2022-11-22
- C/C++编程中const的使用详解 2023-03-26
- C++使用easyX库实现三星环绕效果流程详解 2023-06-26
- 详解c# Emit技术 2023-03-25
- C语言基础全局变量与局部变量教程详解 2022-12-31
- C++中的atoi 函数简介 2023-01-05
- C语言 structural body结构体详解用法 2022-12-06
- 一文带你了解C++中的字符替换方法 2023-07-20
- C++详细实现完整图书管理功能 2023-04-04
- 如何C++使用模板特化功能 2023-03-05