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