In OpenCV, a video can be read either by using the feed from a camera connected to a computer or by reading a video file. The first step towards reading a video file is to create a VideoCapture object.
In this post, we will provide a bash script for installing OpenCV-4.0.0 (C and Python 3.7) on macOS – High Sierra and Mojave. We will also briefly study the script to understand what’s going in it. Note that this script will install OpenCV in a local directory and not on the entire system. Let’s jump in 🙂. Free download page for Project OpenCV's opencv-3.1.0.exe.The Open Source Computer Vision Library has 2500 algorithms, extensive documentation and sample code for real-time computer vision. It works on Windows, Linux, Mac OS X, Android and iOS. Opencv For Mac; Opencv 3.1 Download; In OpenCV, a video can be read either by using the feed from a camera connected to a computer or by reading a video file. The first step towards reading a video file is to create a VideoCapture object. At this point, you should have OpenCV 4 and Python installed on your Mac. We can write a small test program that will print the OpenCV version, load an image from the disk, convert the image to gray and show the result. Start by downloading the next image: Save it as clouds.jpg.
I have trawled through all of Google's and Stack Overflow's search results in order to install stupid OpenCV on my Mac and all the methods have been completely useless.
I started trying to do this with OS X 10.8 and its XCode version and it didn't work. Now I'm on 10.9 and XCode 5.0.1.
I have tried mainly 2 methods:1) Downloading the .dmg file from OCV website and doing the CMAKE routine. When I get to the make -j8 step, at around 36% it gives me errors such as:
-make[1]: * [modules/imgproc/CMakeFiles/opencv_perf_imgproc.dir/all] Error 2
-Documents/Libraries/opencv-2.4.6.1/modules/ts/include/opencv2/ts/ts_perf.hpp:480:12: note: expanded from macro 'CV_PERF_TEST_MAIN_INTERNALS' while (++argc >= (--argc,-1)) {VA_ARGS; break;} /this ugly cons.. ^ ~~1 error generated.make[2]: ** [modules/imgproc/CMakeFiles/opencv_perf_imgproc.dir/perf/perf_main.cpp.o] Error 1
2) Using Homebrew at the end of which, even if I added the python path, when I do 'import cv' it gives me a 'no module named cv' error
I tried Macports as well a while ago so I don't remember the steps, but it didn't work.
It goes without saying that I've tried different versions of OCV and all have given me issues at the make step.
Any other solutions?
Rupert Cobbe-WarburtonRupert Cobbe-Warburton2 Answers
There is a great tutorial located here. It highlights that the version you are trying to use 'is not compatible'. I am thinking that you should try installing the version stated in those instructions and see how you go.
The following instructions are taken directly from that link:
INSTALLING CMAKE
First you need to download the .dmg file under Binary Distribution of CMake here. At the time of I installed this, the file name is cmake-2.8.11.2-Darwin64-universal.dmg.
Upon completion of the installation you will be prompted whether to put CMake in /usr/bin, select Yes and finish installation
To ensure that CMake has been successfully installed, type cmake -version in Terminal
INSTALLING OPENCV
First, download the tar file of OpenCV 2.4.3 stable version here and DO NOT use the latest version. I struggled with the installation because I used OpenCV 2.4.6.1 and it's not yet compatible.
Extract the tar file in a folder and go to that folder through the terminal, e.g. cd Downloads/OpenCV-2.4.3
Now, each of the following line is to be executed in Terminal and must be executed successfully (no error)
mkdir build
cd build
cmake -G 'Unix Makefiles' .
make -j8
sudo make install
You are all set to use OpenCV!
Opencv For Mac
Steps for those who prefer to build opencv from source
I prefer to use cmake-gui
instead of entirely doing this from command line, since that gives you more idea about the options available for opencv configuration and bring you in better position if you want to customize opencv build tomorrow ( like enabling java wrapper or OpenCL etc ).
- Download source either from opencv.org(1) or opencv githubrepo(2)
- Start cmake-gui.
- Set
source path
to downloaded opencv directory andbuild path
toyour choice and click Configure button. - Specify generator as unix makefiles and pressContinue
- Choose compilers and click Done button.
- An options page with errors might be listed.
- Hovering mouse over any option gives a tooltip about the option. Edit option(s) as you feel fit. E.g.
CMAKE_INSTALL_PREFIX
- change opencv install pathBUILD_SHARED_LIBS
- build static or shared library. etc
Then click Configure again. If there are still errors, edit the option(s) causing the error and click Configure button. Repeat the edit / Configure cycle until there are no more errors. Once there are no more errors, proceed to step (8).
A minimal sample config of the WITH
tab below. Feel free to play with options. This might cause build problems initially. But your understanding of build, will be better.
- Click Generate to generate make files.
- Type
make
( in terminal at build folder ) - Type
make install
Opencv 3.1 Download
Not the answer you're looking for? Browse other questions tagged opencvcmake or ask your own question.
How do I download OpenCV on Mac?
Install OpenCV 3 on MacOSStep 1: Install XCode. Install XCode from App Store. Step 2: Install Homebrew. Launch a terminal from Launchpad. Step 3: Install Python 2 and Python 3. Step 4: Install Python libraries in a Virtual Environment. Step 5: Install OpenCV. Step 6: Make OpenCV3 Python symlink in our virtual environment. Step 7: Test OpenCV3.
How do I know if OpenCV is installed on my Mac?
How to check if OpenCV is installed on a machine, It’s simple just shoot up a terminal and type $ pkg-config –modversion opencv 2.4. 9 (output) you will get the opencv version installed in my case it’s 2.4.
How do I know which CV is open?
Checking your OpenCV version using Python$ python.>>> import cv2.>>> cv2.__version__’3.0. 0′
How do I know if cv2 is installed?
After installation, it is recommended that you can check the version of OpenCV that Python is using: import cv2 print cv2. __version__ # Should print 3.0. 0-rc1 or newer.
Does Mac come with PIP?
MacOS comes with Python installed. But to make sure that you have Python installed open the terminal and run the following command. After that, pip will be installed and you’ll be able to use it for installing other packages.
Where is Python installed on Mac?
The Apple-provided build of Python is installed in /System/Library/Frameworks/Python.
How do I get PyGame on my Mac?
Installation of PyGame on Mac:Start by opening Spotlight search bar on your Mac. Once you have opened the Spotlight search bar, type terminal in the bar to open terminal.Now type pip3.If you see a bunch of general options on the screen, it means that pip is already installed on your MacBook.
How do I install VENV on my Mac?
Enter the following commands:Install Pip. ( Python Package Installer): Install virtualenv: Copy sudo pip install virtualenv.Navigate to where you want to store your code. You have two options: Create a new virtualenv: Copy virtualenv yourenv -p python3.6. Activate virtualenv: Install Django: Happy Coding with Django.
Where is Virtualenv installed on Mac?
It will get installed in the venv/ folder, and not conflict with other projects. Important: Remember to add venv to your project’s .
How do I install text requirements?
1 AnswerFirstly, remove matplotlib1.3.1 from requirements.txt.After that try to install it with sudo apt-get install python-matplotlib.Run pip install -r requirements.txt (Python 2), or pip3 install -r requirements.txt (Python 3)pip freeze > requirements.txt.
Install Opencv On Mac
How do I run Django on a Mac?
Starting a Python-Django Project On Mac OS XInstall HomeBrew.Install python3.Install VirtualEnvironment.cd to project directory and create virtualenv.activate virtualenv.Install django.Create your project.Hoorah!!! Just start it now.
How do I run Python on Mac?
Install Cv2 Mac
You can run a Python interpreter by double-clicking on Applications / Utilities / Terminal and typing python3 (if you’ve installed a version of Python 3) or python (to use Python 2) in the window that opens up.
How do I start a Django project?
Download Opencv For Mac
To get started:Use the django-admin tool to generate a project folder, the basic file templates, and manage.py, which serves as your project management script.Use manage.py to create one or more applications. Register the new applications to include them in the project.