Skip to content

Instantly share code, notes, and snippets.

Last active Jan 22, 2022
What would you like to do?
Install opencv on mac

Install opencv3 with brew

brew tap homebrew/science
brew install opencv3

Be sure to have pkg-config, otherwise install it:
brew install pkg-config

be sure to have pkg-config var set correctly
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig/

Opencv comes with it's own .pc, move it or simlink it to the PKG_CONFIG_PATH
ln -s /usr/local/opt/opencv3/lib/pkgconfig/opencv.pc $PKG_CONFIG_PATH

Add to ~/.profile file (create it if necessary)

export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig/
alias opencvflags="pkg-config --cflags --libs opencv"

source ~/.profile

Compile using pkg-config
g++ `opencvflags` GetImageWebCam.cpp
g++ $(pkg-config --cflags --libs opencv) GetImageWebCam.cpp

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment