OpenCV (1) Installation and configuration of OpenCV under Mac

Homebrew introduction and installation

This part is transferred from the blog of the great god, the lazy fat rabbit . The original blog address is the
lazy fat rabbit Homebrew official website http://brew.sh/index_zh-cn.html

  1. Homebrew is a god horse

The Linux system has a common problem, which is package dependencies. Fortunately, the two current mainstream distributions have their own solutions. Red hat has yum, and Ubuntu has apt-get.

Shenma, you use mac os, sorry that Mac os doesn't have similar stuff, after many toss and tears, I finally found third-party support: Homebrew, Homebrew referred to as brew, is a package management tool on Mac OSX, which can be used on Mac It can be said that Homebrew is the apt-get and yum artifact under mac.

  1. Homebrew installation

The installation of Homebrew is very simple, open the terminal and copy and paste the following commands, press Enter, and you are done (please use it with confidence, the original official installation method is carried)

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
  1. Homebrew use

There is nothing to say about Homebrew use, commonly used

Search software: brew search software name, such as brew search wget

Install software: brew install software name, such as brew install wget

Uninstall software: brew remove software name, such as brew remove wget

more? Go to the official website to dig it yourself http://brew.sh/index_zh-cn.html

Note: This article is original by Lazy Fat Rabbit, and the copyright belongs to the author and the blog garden. Reprints are welcome, but this statement must be retained without the author's consent, and a link to the original text is given in an obvious position on the article page. If you think this article is not bad, please click the recommendation in the lower right corner. With your support, the author will be able to inspire greater enthusiasm for writing. Thank you very much. If you have any questions, you can contact me at [email protected].


end of reference

unable to access ‘https://github.com/Homebrew/brew/‘: Failed to connect to github.com

The above error occurs because Github is blocked. The solution is to modify the hosts file
MAC method: Fidner->Go to folder->/private/etc
After finding the hosts file, copy it to the desktop, then open it on the desktop, and add the following lines. If the following fails, you can find a new IP

192.30.253.118 http://gist.github.com
192.30.253.119 http://gist.github.com
192.30.253.113 github.com

After the modification is completed, replace the hosts under the /private/etc folder with the desktop hosts.

1. Install wget

Method: Enter the following command

brew install wget

2. Install cmake

Method: Enter the following command

brew install cmake

3. Install OpenCV

 brew install opencv

The location where Opencv is installed is: /usr/local/Cellar/opencv
write picture description here
Next, we can configure OpenCV. First, create a new project in XCode. After creating a new project, add dependencies and header files.
write picture description here
Double-click the first box, and then click on the lower left corner. +, you can add the address
write picture description here

Then create a new folder under the project, and drag the files with the suffix .dylib under /usr/local/Cellar/opencv/3.4.1_4/lib into this folder.

PS: After I opened it, I found a lot. The Internet said that the number of files was 18, and then a great god said that the ones with arrows should not be ignored, so I only dragged the ones without arrows, but they exceeded 18. Maybe my version is relatively new. Then you're done, find and test the test code yourself.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325610035&siteId=291194637