当前位置:网站首页>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)
边栏推荐
- The mouse wheel of xshell/bash/zsh and other terminals is garbled (turn)
- R language ggplot2 visualization: gganimate package creates animated graph (GIF) and uses anim_ The save function saves the GIF visual animation
- CVPR 2022 | greatly reduce the manual annotation required for zero sample learning, and propose category semantic embedding rich in visual information (source code download)
- 去除重复字母[贪心+单调栈(用数组+len来维持单调序列)]
- R语言使用lattice包中的bwplot函数可视化箱图(box plot)、par.settings参数自定义主题模式
- IP lab monthly resumption · issue 5
- 软件测试之测试评估
- Understand chisel language thoroughly 12. Chisel project construction, operation and testing (IV) -- chisel test of chisel test
- Understand chisel language thoroughly 11. Chisel project construction, operation and test (III) -- scalatest of chisel test
- Whether the loyalty agreement has legal effect
猜你喜欢
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
Excel快速合并多行数据
MySQL version 8 installation Free Tutorial
Why should Base64 encoding be used for image transmission
【信息检索】分类和聚类的实验
sharding key type not supported
[FAQ] Huawei Account Service Error Report 907135701 Common reasons Summary and Solutions
C # WPF realizes the real-time screen capture function of screen capture box
C# wpf 实现截屏框实时截屏功能
nowcoder重排链表
随机推荐
flink sql-client.sh 使用教程
[R language data science]: cross validation and looking back
Golang 使用 JSON unmarshal 数字到 interface{} 数字变成 float64 类型(转)
Read excel table data
安装Mysql
How to package QT and share exe
Rich text editing: wangeditor tutorial
Code hoof collection of wonderful secret place
Ws2818m is packaged in cpc8. It is a special circuit for three channel LED drive control. External IC full-color double signal 5v32 lamp programmable LED lamp with outdoor engineering
392. Judgement subsequence
Assertion of unittest framework
Common content type correspondence table
去除重复字母[贪心+单调栈(用数组+len来维持单调序列)]
Hardware Basics - diode Basics
Excel快速合并多行数据
Understand chisel language thoroughly 10. Chisel project construction, operation and testing (II) -- Verilog code generation in chisel & chisel development process
R language dplyr package summary_ If function calculates the mean and median of all numerical data columns in dataframe data, and summarizes all numerical variables based on conditions
MySQL 5 installation and modification free
Matters needing attention in overseas game Investment Agency
MATLAB中tiledlayout函数使用