Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I install opencv2 with brew under OSX

Recently, I installed opencv with the following command:

brew install opencv

I found opencv3 was installed in dir /usr/include and /usr/lib. But what I want is opencv2. How can install opencv2 with the brew command?

like image 659
Ayoung Avatar asked Sep 06 '17 04:09

Ayoung


People also ask

How do I import my cv2 library?

Start the Python shell by typing python3 and then hit enter. You will be inside the Python shell where you can execute your Python code. Import the cv2 package which is the name of the OpenCV module. Type “import cv2” and hit enter.


2 Answers

The easiest way to find the answer is to use brew search to look for available packages. So, in your case:

brew search opencv

There you will see the package opencv@2 listed. So, you need:

brew install opencv@2
like image 189
Mark Setchell Avatar answered Sep 20 '22 21:09

Mark Setchell


I can't give you a answer in context of using brew but I can assist you with a valuable resource that really helped me out when I was first started out with OpenCV that got me up and developing https://www.youtube.com/watch?v=U49CVY8yOxw

  1. Install Xcode , Install C-Make

  2. Download OpenCV source code https://github.com/opencv/opencv/releases/tag/3.1.0

  3. Build and install!

INSTRUCTIONS: Go inside OpenCV once downloaded create new folder called build. Next, open CMake GUI find the directory we just created " build " to build the binaries, Click configure, Select "Unix Makefiles" and use native default compilers. cd into out build directory in our OpenCV folder so something like this /Users/you/Desktop/openCvFolder/build and run the command "make" and go have a coffee! I hope this helps it helped me out when I first started experimenting a year ago with OpenCV

like image 30
TravHola Avatar answered Sep 20 '22 21:09

TravHola