command line installation
- ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)
- brew install wget
- brew install cmake
- brew install opencv will automatically choose to install OpenCV 4.1.0 version
Xcode project configuration
- Create a new Command Line Tool project and select C++ as the language.
- Click on the project to find "Search Paths" and add related directories:
a. Header Search Paths - add "/usr/local/include/opencv4"
b. Library Search Paths - add "/usr/local/lib" and "/usr /local/Cellar/opencv/4.1.0_2/lib" - Right-click the project to create a new folder (Group) and drag the "*.dylib" file in the "/usr/local/Cellar/opencv/4.1.0_2/lib" folder into it
test
#include <iostream>
#include <opencv2/opencv.hpp>
using namespace cv;
int main(int argc, const char * argv[]) {
//! 读入一个图片,在此其路径是"/Users/tang/testPic.jpg"
Mat mat_image_src = imread("/Users/tang/testPic.jpg");
imshow("before",mat_image_src);
Mat mat_image_dst;
Canny(mat_image_src, mat_image_dst, 20, 50);
imshow("after Canny", mat_image_dst);
waitKey();
return 0;
}
result