1. App Store download Xcode
2. OpenCV official website Download OpenCV for Linux/mac
3. Installing homebrew
4. Command line install CMake using brew install CMake
5.cd to OpenCV the extracted folder, then execute the following command in the command line:
mkdir build
cd build
cmake -G
"Unix Makefiles"
..
make
sudo make install
At this point, OpenCV installs into the Xcode new command line Mac Ox Program, using the C + + language 1. Search in the Project Build setting window to modify the following items in the Always search User Paths:trueframewo RK Search Path:/usr/local/libheader search Paths:/usr/local/include
Library Search Paths:/usr/local/lib2.build setting window for other linker flags input-Lopencv_calib3d-lopencv_core -lopencv_features2d -lopencv_flann -lopencv_highgui -lopencv_imgcodecs -lopencv_imgproc - lopencv_ml -lopencv_objdetect - Lopencv_photo -lopencv_shape -lopencv_stitching Span class= "o" >-lopencv_superres -lopencv_ts -< span class= "n" >lopencv_video -lopencv_videoio - Lopencv_videostab 3. location->advanced in Xcode preferences,
UniqueSwitch
Legacy.4. Create a new folder in the project, select "Add files to ...", press command+shift+g input path/usr/local/lib, add all lib files to 5. Complete! Can be tested with the following code, the picture path of the test itself modified:
#include <opencv2/core/core.hpp>#include<opencv2/imgcodecs.hpp>#include<opencv2/highgui/highgui.hpp>#include<iostream>#include<string>using namespaceCV;using namespacestd;intMainintargcChar**argv) { stringImageName ("/users/isware/documents/matlab/walrus_001.jpg");//by default if(Argc >1) {ImageName= argv[1]; } Mat image; Image= Imread (Imagename.c_str (), imread_color);//Read the file if(Image.empty ())//Check for Invalid input{cout<<"Could not open or find the image"<<Std::endl; return-1; } Namedwindow ("Display window", window_autosize);//Create a window for display.Imshow ("Display window", image);//Show our image inside it.Waitkey (0);//Wait for a keystroke in the window return 0; }
OpenCV installation under Mac and configuration in Xcode