Skip to content

Instantly share code, notes, and snippets.

@nkcr
Last active January 22, 2022 17:06
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nkcr/6f5c6db4dccd3b32e8ba to your computer and use it in GitHub Desktop.
Save nkcr/6f5c6db4dccd3b32e8ba to your computer and use it in GitHub Desktop.
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"

then
source ~/.profile

Compile using pkg-config
g++ `opencvflags` GetImageWebCam.cpp
Or
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