andresouris andresouris - 13 days ago 8
C++ Question

Install openCV on xcode for c++

I have problems to install openCV on xcode in order to develop in C++.
I tried to follow this tutorial

But, I have a problem when I do the

make
command in the terminal, I have this kind of error:


fatal error:

'QTKit/QTKit.h' file not found

#import

1 error generated.

make[2]: ***

[modules/highgui/CMakeFiles/opencv_highgui.dir/src/cap_qtkit.mm.o] Error 1


Do you have any solution?

Answer

Try to install OpenCV through homebrew. To do this, open terminal and run the following commands.

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" 
brew install homebrew/science/opencv3

Last command will install OpenCV3 and all dependencies in /usr/local/Cellar/opencv3/3.1.0.3/

Then you can link .dylib and .h/.hpp files to your XCode project and use OpenCV.

If you have any questions, I'm happy to answer them.

[EDIT]: If you use macOS 10.12 or later, install OpenCV with following commands.

brew install opencv3 --with-ffmpeg --with-tbb --with-contrib
brew reinstall opencv3 --HEAD --with-python3 --with-ffmpeg --with-tbb --with-contrib