OpenCV的项目构建使用的是CMake.
简单的实现一个Demo 来实现在Mac上的C++测试,效果如下:
在Mac上使用HomeBrew安装:
brew install opencv
安装成功后,简单测试一下使用、
CMakeLists.txt
#设置版本号
cmake_minimum_required(VERSION 3.5)
project(OpenCV_Test)
set(CMAKE_CXX_STANDARD 11)
find_package(OpenCV REQUIRED)
include_directories(${OpenCV_INCLUDE_DIRS})
set(CMAKE_CXX_STANDARD 11)
add_executable(OpenCV_Test main.cpp)
target_link_libraries(OpenCV_Test ${OpenCV_LIBS})
main.cpp:
#include
#include
#include<string>
using namespace cv;
voidImageThreshold(std::string str) {
Mat image = imread(str);
imshow("test_opencv",image);
waitKey(0);
}
int main() {
std::string str ="/Users/huangshiping/Desktop/aaa.png";
ImageThreshold(str);
return0;
}
在当前目录下执行:
cmake .
make
./OpenCV_Test
网友评论