A memo when building an environment of OpenCV using homebrew. From initial setting to sample execution.
Mac mini(2012),OS X Yosemite(10.10.5) OpenCV2
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.
** 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
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.
Put OpenCV in OS X with Homebrew and input / output video with python How to install OpenCV with Homebrew
As an aside, next I would like to try building an Ubuntu OpenCV environment.
Recommended Posts