"OpenCV" Mac OS x platform uses Xcode to build OpenCV environment

Source: Internet
Author: User

This paper describes how to build a OPENCV environment under the MAC system.

Software Requirements: Mac OS (Mine is 10.11.6), Xcode (My is 8.1), OpenCV (not recommended to the official website to download first, the specific follow-up will be explained).

1. Installation Homebrew  Brew official website

Installation method: Open Mac Terminal, enter the following command:



Ruby-e "$ (curl-fssl https://raw.githubusercontent.com/Homebrew/install/master/install)"


Here's how the brew's official web site will give you an installation command, which I tried while installing, but failed to install.

Tip: After the installation is successful, the terminal will prompt ==>installation successful!

==>next steps

2. Installation CMake

Before installing CMake, use the command


Brew Self Update

Update homebrew and install CMake.

Installation method: Enter the following command at the terminal:



Brew Install CMake


3. Installation OpenCV

The home-brew is used to install the OPENCV instead of downloading it.

Enter the following command at the terminal:


Brew Install OpenCV

Note: There may be a problem like "Error:no available formula for OpenCV" At this point, the terminal will give some reason and hint, the installation literal meaning can be handled, I use the following command to solve this problem during the installation process:


Brew Install HOME-BREW/SCIENCE/OPENCV

Brew helps us download OPENCV instead of downloading them on the OPENCV website, eliminating the hassle of OpenCV and Xcode mismatches, and allowing brew to choose the system that best fits its version.

4, under the Xcode use OpenCV

4.1, use Xcode to create a command line Tools, here and create a common Xcode C + + program is the same.

4.2. Click Project (top left, blue one), select targets-> Right select All->build Settings-> search box input search paths-> Select Search Paths the following header Search PARHS-> Double click the details below to add the specified path:/usr/local/include (some of the posts here say you need to install a second path:/USR/LOCAL/INCLUDE/OPENCV, I only install the first one on my system to run, depending on the situation. Then choose search paths below the library search PARHS-> Double-click to add the specified path:/usr/local/lib (this contains the required library files).

4.3, under the Xcode project to establish a newgroup

Method: Right-click Project (top left, blue one), then click "New Group". Then, turn on the Mac "Finder", by holding down Shift +command+ g three keys, the system will pop up a dialog box, and then enter "/usr/local" after the point of return, it will be transferred to the local folder, and then in the following order to enter: Cellar-->opencv-->2.4.3-->lib, you can see a lot of files ending with "Dylib" (these files will have some version with arrows, don't bother), these are "dynamic libraries", Then you find the following three dynamic libraries (if you do more complex image work, you can include all 18 libraries, where the test cases use the following 3 libraries on it):



[A] libopencv_core.2.4.3.dylib  
[b] Libopencv_highgui.2.4.3.dylib
[c] Libopencv_ml.2.4.3.dylib

When you select them, drag them directly into the NewGroup folder that you just built in the Xcode, and then Xcode will pop up a dialog box, note that do not check "Copy items into Destination Group ' folder (if needed)", Then click "Finish" and it's done.


After the above configuration is complete, Xcode can be used with OPENCV.

Related Article

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.