Installation and trial of OPENCV in Mac system

Source: Internet
Author: User

1. In the Mac terminal, using Brew to install OPENCV3, my OpenCV is installed in/usr/local/cellar/opencv3/3.2.0.

2. Create a new Xcode project, select command Line tool, create a new group within the project directory, and add the dylib containing LIBOPENCV within the/usr/local/cellar/opencv3/3.2.0/lib.

3. Change header search Paths to/usr/local/cellar/opencv3/3.2.0/include in build settings, Library search Paths more/usr/local/ Cellar/opencv3/3.2.0/lib. Note that this cannot be copied online only/usr/local/include or/usr/local/lib, depending on your OPENCV installation address

4. Enter in the main function, you can display the picture, note that the path to the picture is correct, you decide.

#include "OPENCV2/CORE.HPP"

#include "OPENCV2/IMGCODECS.HPP"

#include "OPENCV2/HIGHGUI.HPP"

#include <iostream>

#include <string>

Using namespace cv;

Using namespace std;

int Main (int argc, Char* * argv)

{

String imageName ("/users/mac-jcc/desktop/opencv-00/jcc.png");

Mat image;

Image = Imread(imageName, imread_color);

if(image. Empty())

{

cout<<"could not open or find the image"<<std::endl;

return -1;

}

      

Namedwindow( "Display window", window_autosize );

imshow( "Display window", image );

waitkey(0);

return 0;

}

Installation and trial of OPENCV in Mac system

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.