当前位置:网站首页>opencv3.2 和opencv2.4安装
opencv3.2 和opencv2.4安装
2022-07-04 12:51:00 【wu_zhiyuan】
OpenCV2和3共存:
如果2默认编译安装了,那么2的库位置应该在/usr/local/lib ,再CMakeLists.txt中 find_package,系统默认会找/usr/local/share/OpenCVConfig.cmake
再下载3源码,解压后
mkdir build
cd build
更改安装目录(先在/usr/local下新建文件夹opencv3)
cmake -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=/usr/local/opencv3 ..
编译:
make -j
sudo make install
这样就把3安装在opencv3文件夹了(bin lib share include)
在使用的时候,在CMakelists.txt中,如要用3,在find_package前指明路径:
set(OpenCV_DIR /usr/local/opencv3/share/OpenCV)
find_package(OpenCV 3 REQUIRED)
用2的时候:
find_package(OpenCV 2 REQUIRED)
如果要用gdb调试,需要在txt中:
SET(CMAKE_BUILD_TYPE "Debug")
不过这样会减慢编译速度
如果要用C++11:
add_definitions(-std=c++11)
最简单的流程:
cmake_minimum_required(VERSION 2.8)
project(XXX)
#指定编译器:
SET(CMAKE_C_COMPILER g++)
#找到要用的包:
find_package(OpenCV 3 REQUIRED)
include_directories(
${
PROJECT_SOURCE_DIR}
#其他头文件路径
)
#创建库:
add_library(${
PROJECT_NAME} SHARED
XXXXX.cpp
)
\#给库链接到开源库
target_link_libraries(${
PROJECT_NAME}
${
OpenCV_LIBS}
)
#生成可执行文件,链接到创建的库
add_executable(main main.cpp)
target_link_libraries(main ${
PROJECT_NAME})
eigen的使用
首先需要在根目录
mkdir cmake_modules
并在cmake_modules里放进 FindEigen3.cmake文件
然后:
set(CMAKE_MODULE_PATH ${
PROJECT_SOURCE_DIR}/cmake_modules)
#或者 LIST(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake_modules)
find_package(Eigen3 REQUIRED)
include_directories( ${
EIGEN3_INCLUDE_DIR} )
补充:
opencv 解决ippicv下载问题,离线:ippicv_2019_lnx_intel64_general_20180723.tgz
https://blog.csdn.net/orDream/article/details/84311697
OpenCV必须make install 安装到其他地方,不然相关头文件找不到,还有必须指定头文件路径,否则找不到。
set(OpenCV_DIR /usr/local/opencv3/share/OpenCV)
#注释的这种不好,不推荐
#set(OpenCV_DIR /home/guoxianzheng/opencv-3.4/build)
find_package(OpenCV 3 REQUIRED)
message(STATUS "This is opencvdir ${OpenCV_DIR}")
include_directories(
${
OpenCV_DIR}
)
include_directories(/usr/local/opencv3/include)
边栏推荐
- qt 怎么检测鼠标在不在某个控件上
- Hardware Basics - diode Basics
- 吃透Chisel语言.07.Chisel基础(四)——Bundle和Vec
- 海外游戏代投需要注意的
- R语言ggplot2可视化:gganimate包创建动态折线图动画(gif)、使用transition_reveal函数在动画中沿给定维度逐步显示数据
- Huahao Zhongtian rushes to the scientific and Technological Innovation Board: the annual loss is 280million, and it is proposed to raise 1.5 billion. Beida pharmaceutical is a shareholder
- 卷积神经网络经典论文集合(深度学习分类篇)
- 去除重复字母[贪心+单调栈(用数组+len来维持单调序列)]
- Use of arouter
- 如何游戏出海代运营、游戏出海代投
猜你喜欢
JVM memory layout detailed, illustrated, well written!
递增的三元子序列[贪心训练]
Supprimer les lettres dupliquées [avidité + pile monotone (maintenir la séquence monotone avec un tableau + Len)]
Unity Shader学习(三)试着绘制一个圆
Ruiji takeout notes
1200. Minimum absolute difference
安装Mysql
92.(cesium篇)cesium楼栋分层
迅为IMX6Q开发板QT系统移植tinyplay
富文本编辑:wangEditor使用教程
随机推荐
Use the default route as the route to the Internet
Test process arrangement (2)
R language ggplot2 visualization: gganimate package creates dynamic line graph animation (GIF) and uses transition_ The reveal function displays data step by step along a given dimension in the animat
Understand chisel language thoroughly 10. Chisel project construction, operation and testing (II) -- Verilog code generation in chisel & chisel development process
How to operate and invest games on behalf of others at sea
2022 practice questions and mock exams for the main principals of hazardous chemical business units
Matters needing attention in overseas game Investment Agency
Haobo medical sprint technology innovation board: annual revenue of 260million Yonggang and Shen Zhiqun are the actual controllers
Assertion of unittest framework
如何游戏出海代运营、游戏出海代投
学内核之三:使用GDB跟踪内核调用链
测试流程整理(3)
Mongodb commonly used 28 query statements (forward)
sql优化之查询优化器
mac redis安装与使用,连接远程服务器 redis
nowcoder重排链表
PHP log debugging
Install MySQL
数据仓库面试问题准备
Golang uses JSON unmarshal number to interface{} number to become float64 type (turn)