OpenCV installation under Mac and configuration in Xcode

Source: Internet
Author: User

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 installAt 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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.