Configuration of OpenCV under Mac

Source: Internet
Author: User

I just changed my Mac a lot of things don't configure the environment every time you have to toss a big pot

This time the OpenCV nonsense not much to cut into the chase

1. Preparatory work:

In the terminal, enter:

    ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"              //这里网上有的教程是用github的,github老是被墙反正我有时候翻不过去

Download homebrew (use it to install the UNIX-related tools software without the help of the terminal) attached to a learning link (http://www.zhouming.me/2011/07/mac-os-x-homebrew-install/)

2. Install the CMake: (used in the 1-loaded tool)

In the terminal, enter:

    Brew Install CMake

3. Install OpenCV:

Method One: (This installs the installation is OpenCV 2.4.9)

    Brew Install OpenCV

If it appears

Error:no available formula for OpenCV (I showed up 2333)

Enter the brew install OPENCV before entering

    Brew Tap homebrew/science (will snap directly into brew install OPENCV OK)

Method Two: (Can install opencv3.0)

First download the OPENCV package, and then in the terminal into the OpenCV folder after unpacking, create a new empty folder release, enter the folder, compile and install OPENCV, using the command as follows:

mkdir Release

CD release

Cmake-g "Unix makefiles". (will be a card directly input make OK)

Make

sudo make install

    The installed Lib file is stored in the "/usr/local/lib" folder and the H file is stored in "/usr/local/include". (Auto-complete is not manual)

At this point, the OpenCV for MAC installation is complete, the reference URL is as follows:http://docs.opencv.org/doc/tutorials/introduction/linux_install/linux_install.html#linux-installationhttp://tilomitra.com/opencv-on-mac-osx/4. Use OpenCV in Xcode and Eclipse:Xcode:1. Create a new command line project (here's the estimate and the command line tools at the very beginning.) 2. Create a new CPP and paste a OPENCV program to test

//

Main.cpp

Opencv_test

//

Created by Li Zehou on 14/11/5.

Copyright (c) 2014 ___vissac___. All rights reserved.

//

#include <iostream>

#include <opencv2/opencv.hpp>

#include <opencv2/highgui/highgui.hpp>

#include <opencv/cvaux.hpp>

#include <fstream>

using namespace Std;

#define BYTE unsigned char

int main (int argc, const char * argv[])

{

Insert code here ...

#if 1

Get the image from the directed path

iplimage* img = cvloadimage ("/users/lize/aaa.png", 1);

NSLog (IMG);

Create a window to display the image

Cvnamedwindow ("Picture", 1);

Show the image in the window

Cvshowimage ("Picture", IMG);

Wait for the user to hit a key

Cvwaitkey (0);

Delete the image and window

Cvreleaseimage (&IMG);

Cvdestroywindow ("picture");

#endif

Return

return 0;

}

3. Add lib file: Right click on the project name, select "Add files to ..." and press "/" to enter:/usr/local/lib (note this step, if using MacPorts, the path is not the same), Select all files under this folder that are Dylib and add to the project4. Add lib file lookup support: Click the file name folder, in the main interface "Building Settings" tab, double-click "Library Search Paths", add the path "/usr/local/lib"5. Add header file: Click on the project name file, or in the "Building Settings" tab, find "header Search Paths", add "/usr/local/include" and "/usr/local/include /opencv "6. Compile link run, no, no, Google, I'm successful anyway. 2333Eclipse:1. Right-click the project name, select Properties, then click the drop-down arrow to the left of the C + + build, select Settings, and select tool settings in the Right tab .2. Select includes in the GCC C + + Compiler Options list and add/usr/local/include/in Paths3. Select Libraries in the MacOS X C + + linker Options list to add/usr/local/lib/to the library search path, Add the Lib file you need to use in libraries: (don't know what you need to add it all, and then ask Google for questions)Opencv_coreOpencv_imgprocOpencv_highguiopencv_mlOpencv_videoopencv_features2dopencv_calib3dOpencv_objdetectOpencv_contribopencv_legacyOpencv_flannReference:http://blog.sciencenet.cn/home.php? Collcc=3456986939&collcc=3456885714&mod=space&uid=702148&do=blog&quickforward=1&id= 657754%20%e5%9c%a8mac%e4%b8%8b%e4%bd%bf%e7%94%a8opencv%ef%bc%8c%20%e5%9c%a8xcode%e4%b8%8b%e4%bd%bf%e7%94% A8OPENCV

Configuration of OpenCV under Mac

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.