opencv找不到路径

安装opencv库后总是找不到路径,可能寻找opencv库的方式不一样

cmake_minimum_required( VERSION 2.8 )
project( imageBasics )

# 添加c++ 11标准支持
set( CMAKE_CXX_FLAGS "-std=c++11" )

# 寻找OpenCV库
set(Opencv_DIR /home/li/opencv-3.1.0/build)
find_package( Opencv  NAMES OpenCV REQUIRED)#或者用find_package(OpenCV REQUIRED)
if(Opencv_FOUND)
message(STATUS "The Opecv lib is found!") 
endif()
# 添加头文件
include_directories( ${OpenCV_INCLUDE_DIRS} )

add_executable( imageBasics imageBasics.cpp )
# 链接OpenCV库
target_link_libraries( imageBasics ${OpenCV_LIBS} )

运行程序需在终端

li@Vostro:~$ cd slambook/
li@Vostro:~/slambook$ ls
3rdparty  ch11  ch13  ch3  ch5  ch7  ~$errata.xlsx  LICENSE  README.md
ch10      ch12  ch2   ch4  ch6  ch8  errata.xlsx    project  tools
li@Vostro:~/slambook$ cd ch5
li@Vostro:~/slambook/ch5$ ls
imageBasics  joinMap
li@Vostro:~/slambook/ch5$ cd imageBasics/
li@Vostro:~/slambook/ch5/imageBasics$ ls
build  CMakeLists.txt  imageBasics.cpp  imageBasics.kdev4  ubuntu.png
li@Vostro:~/slambook/ch5/imageBasics$ build/imageBasics ubuntu.png 
图像宽为1200,高为674,通道数为3
遍历图像用时:0.0253761 秒。
li@Vostro:~/slambook/ch5/imageBasics$ build/imageBasics ubuntu.png 
图像宽为1200,高为674,通道数为3
遍历图像用时:0.0279489 秒。
li@Vostro:~/slambook/ch5/imageBasics$ 

 

你可能感兴趣的:(学习笔记)