Introducing OpenCV on Mac with homebrew

Overview

A memo when building an environment of OpenCV using homebrew. From initial setting to sample execution.

environment

Mac mini(2012),OS X Yosemite(10.10.5) OpenCV2

at first

I have homebrew installed. ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" For those who have never started xcode

You have not agreed to the Xcode license. Before running the installer again please agree to the license by opening Xcode.app or running: sudo xcodebuild -license

Message appears, start xcode.

Download and install OpenCV and Python

** Python ** related installation brew tap homebrew/science brew install python pip install numpy

** OpenCV ** related installation brew install cmake automake celt faac fdk-aac git lame libass libtool libvorbis libvpx libvo-aacenc opencore-amr openjpeg opus sdl schroedinger shtool speex texi2html theora wget x264 xvid yasm

brew install ffmpeg --with-fdk-aac --with-libvo-aacenc --with-libvorbis --with-libvpx --with-openjpeg --with-theora --with-opencore-amr

brew install eigen brew install jasper brew install tbb brew install qt brew install opencv --with-eigen --with-jasper --with-libtiff --with-qt --with-tbb --with-ffmpeg

Try the sample

Load the image, convert it to a gray image, output.

test.py


import cv2
import numpy as np
import sys

cv2.namedWindow('edge')
img = cv2.imread('test1.jpg')
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
thrs1 =1000
thrs2 =10
edge = cv2.Canny(gray, thrs1, thrs2, apertureSize=5)
cv2.imshow('edge', edge)

cv2.waitKey(0)
cv2.destroyAllWindows()

It should have run successfully.

Related / Reference

Put OpenCV in OS X with Homebrew and input / output video with python How to install OpenCV with Homebrew

Other

As an aside, next I would like to try building an Ubuntu OpenCV environment.

Recommended Posts

Introducing OpenCV on Mac with homebrew
Stumble with homebrew opencv3
Using OpenCV with Python @Mac
Install PyQt5 with homebrew on Mac OS X Marvericks (10.9.2)
tensor flow with anaconda on mac
Introducing MicroPython (Mac) shell with ESP-WROOM-02
How to install OpenCV on Mac
How to install Theano on Mac OS X with homebrew
Error and solution when installing python3 with homebrew on mac (catalina 10.15)
Install opencv on Mac using Anaconda Navigator
Introducing MAMP + Python + SQLAlchemy (Mysql-Python) on Mac
Follow active applications on Mac with Python
Build Python environment with Anaconda on Mac
Video processing using Python + OpenCV on Mac
The story of having a hard time introducing OpenCV with M1 MAC
python on mac
Install OpenCV 4.0 and Python 3.7 on Windows 10 with Anaconda
Try working with Mongo in Python on Mac
Put Python 2.7.x on Mac OSX 10.15.5 with pyenv
Install Python 3 on MacOS Catalina (with Homebrew only)
Install Tensorflow on Mac
Install pyenv on mac
Detect stoop with OpenCV
Binarization with OpenCV / Python
Introduced Boost.python with homebrew
Pyenv + virtualenv on Mac
Install Ansible on Mac
Install Python on Mac
Install Python 3 on Mac
numba installation on mac
Instructions for installing CUDA 7.5 on Mac (El Capitan) + Homebrew
Rotate sprites with OpenCV
MicroPython (mac) with ESP-WROOM-02
Ubuntu 20.04 on raspberry pi 4 with OpenCV and use with python
I want to AWS Lambda with Python on Mac!
Run OpenMVG on Mac
Steps to quickly create a deep learning environment on Mac with TensorFlow and OpenCV
Data Augmentation with openCV
Install Python 3.4 on Mac
Install Caffe on Mac
Install mecab on mac
Troubleshoot with installing OpenCV on Raspberry Pi and capturing
Install mecab-python on Mac
Try deepdream on Mac
Easy TopView with OpenCV
Minimum notes when using Python on Mac (Homebrew edition)
Build a machine learning environment on mac (pyenv, deeplearning, opencv)
Create a Python (pyenv / virtualenv) development environment on Mac (Homebrew)
Intuitive password management with aws ssm on Mac / Linux alias
Connect to centos6 on virtualbox with ssh connection from Mac
Machine learning environment settings based on Python 3 on Mac (coexistence with Python 2)
Notes on deploying pyenv with Homebrew and managing Python versions
Deep Learning with Shogi AI on Mac and Google Colab
Face recognition with Python's OpenCV
"Apple processing" with OpenCV3 + Python3
Try edge detection with OpenCV
Notes on installing dlib on mac
Pyramid + mongodb environment on Mac
Install pygame on python3.4 on mac
Image editing with python OpenCV
Camera capture with Python + OpenCV